From 2c629fa7beb6341724eb8b43ca8b83348ca9ed67 Mon Sep 17 00:00:00 2001 From: anegawa-j Date: Fri, 14 Jul 2023 15:16:14 +0900 Subject: [PATCH] impl integrated image classification task create api --- README.md | 13 ++++++++++ fastlabel/__init__.py | 56 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/README.md b/README.md index b3bde8d..658366d 100644 --- a/README.md +++ b/README.md @@ -463,6 +463,19 @@ task_id = client.create_image_classification_task( - You can upload up to a size of 20 MB. +#### Create Integrated Image Classification Task + +Create a new classification task by integrated image. +(Project storage setting should be configured in advance.) + +```python +task_id = client.create_integrated_image_classification_task( + project="YOUR_PROJECT_SLUG", + file_path="/sample.jpg", + storage_type="gcp", +) +``` + #### Find Task Find a single task. diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index fd069e4..cfc0c09 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -1054,6 +1054,62 @@ def create_image_classification_task( return self.api.post_request(endpoint, payload=payload) + def create_integrated_image_classification_task( + self, + project: str, + file_path: str, + storage_type: str, + status: str = None, + external_status: str = None, + priority: Priority = None, + attributes: list = None, + tags: list = None, + **kwargs, + ) -> str: + """ + Create a single integrated image classification 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', + priority is the priority of the task (default: none) (Optional). + Set one of the numbers corresponding to: + none = 0, + low = 10, + medium = 20, + high = 30, + 'sent_back', 'approved', 'declined', 'customer_declined' (Optional). + attributes is a list of attribute 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/classification" + payload = {"project": project, "filePath": file_path, "storageType": storage_type} + attributes = attributes or [] + tags = tags or [] + if status: + payload["status"] = status + if external_status: + payload["externalStatus"] = external_status + if priority is not None: + payload["priority"] = priority + if attributes: + payload["attributes"] = attributes + if tags: + payload["tags"] = tags + + self.__fill_assign_users(payload, **kwargs) + + return self.api.post_request(endpoint, payload=payload) + def create_sequential_image_task( self, project: str,