diff --git a/README.md b/README.md index c5d5c3b..4bcb994 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,51 @@ task_id = client.create_image_task( - You can upload up to a size of 20 MB. + +#### Create Integrated Image Task + +Create a new task by integrated image. +(Project storage setting should be configured in advance.) + +```python +task_id = client.create_integrated_image_task( + project="YOUR_PROJECT_SLUG", + file_path="/sample.jpg", + storage_type="gcp", +) +``` + +Create a new task with pre-defined annotations. (Class should be configured on your project in advance) + +```python +task_id = client.create_image_task( + project="YOUR_PROJECT_SLUG", + file_path="/sample.jpg", + storage_type="gcp", + annotations=[{ + "type": "bbox", + "value": "annotation-value", + "attributes": [ + { + "key": "attribute-key", + "value": "attribute-value" + } + ], + "points": [ + 100, # top-left x + 100, # top-left y + 200, # bottom-right x + 200 # bottom-right y + ] + }] +) +``` + +##### Limitation + +- You can upload up to a size of 20 MB. + + #### Find Task Find a single task. diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 1181145..27b0be7 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -4,7 +4,7 @@ import os import re from concurrent.futures import ThreadPoolExecutor -from typing import List +from typing import List, Literal import cv2 import numpy as np @@ -830,6 +830,58 @@ def create_image_task( return self.api.post_request(endpoint, payload=payload) + def create_integrated_image_task( + self, + project: str, + storage_type: Literal["gcp"], + file_path: str, + status: str = None, + external_status: str = None, + annotations: list = None, + tags: list = None, + **kwargs, + ) -> str: + """ + Create a single integrated image task. + + project is slug of your project (Required). + storage type is the type of storage where your file resides (Required). e.g.) gcp + file_path is a path to data in your setting storage bucket. Supported extensions are png, jpg, jpeg (Required). + status can be 'registered', 'completed', 'skipped', 'reviewed', 'sent_back', + 'approved', 'declined' (Optional). + external_status can be 'registered', 'completed', 'skipped', 'reviewed', + 'sent_back', 'approved', 'declined', 'customer_declined' (Optional). + annotations is a list of annotation to be set in advance (Optional). + tags is a list of tag to be set in advance (Optional). + assignee is slug of assigned user (Optional). + reviewer is slug of review user (Optional). + approver is slug of approve user (Optional). + external_assignee is slug of external assigned user (Optional). + external_reviewer is slug of external review user (Optional). + external_approver is slug of external approve user (Optional). + """ + endpoint = "tasks/integrated-image" + if not utils.is_image_supported_ext(file_path): + raise FastLabelInvalidException( + "Supported extensions are png, jpg, jpeg.", 422 + ) + + payload = {"project": project, "filePath": file_path, "storageType": storage_type} + if status: + payload["status"] = status + if external_status: + payload["externalStatus"] = external_status + if annotations: + for annotation in annotations: + annotation["content"] = file_path + payload["annotations"] = annotations + if tags: + payload["tags"] = tags + + self.__fill_assign_users(payload, **kwargs) + + return self.api.post_request(endpoint, payload=payload) + def create_image_classification_task( self, project: str,