diff --git a/README.md b/README.md index 686cd28..7f172d4 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ _If you are using FastLabel prototype, please install version 0.2.2._ - [Image Classification](#image-classification) - [Multi Image](#multi-image) - [Video](#video) + - [Video Classification](#video-classification) - [Common](#common) - [Annotation](#annotation) - [Project](#project) @@ -234,6 +235,24 @@ Get tasks. (Up to 1000 tasks) tasks = client.get_image_classification_tasks(project="YOUR_PROJECT_SLUG") ``` +#### Update Tasks + +Update a signle task. + +```python +task_id = client.update_image_classification_task( + task_id="YOUR_TASK_ID", + status="approved", + tags=["tag1", "tag2"] + attributes=[ + { + "key": "attribute-key", + "value": "attribute-value" + } + ], +) +``` + #### Response Example of a single image classification task object @@ -513,6 +532,38 @@ Example of a single image classification task object } ``` +### Video Classification + +Supported following project types: + +- Video - Classification (Single) + +#### Get Tasks + +Get tasks. (Up to 1000 tasks) + +```python +tasks = client.get_video_classification_tasks(project="YOUR_PROJECT_SLUG") +``` + +#### Update Tasks + +Update a signle task. + +```python +task_id = client.update_video_classification_task( + task_id="YOUR_TASK_ID", + status="approved", + tags=["tag1", "tag2"] + attributes=[ + { + "key": "attribute-key", + "value": "attribute-value" + } + ], +) +``` + ### Common APIs for update and delete are same over all tasks. diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index f349ea1..a745640 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -247,6 +247,39 @@ def get_video_tasks( params["limit"] = limit return self.api.get_request(endpoint, params=params) + def get_video_classification_tasks( + self, + project: str, + status: str = None, + tags: list = [], + task_name: str = None, + offset: int = None, + limit: int = 100, + ) -> list: + """ + Returns a list of video classification tasks. + Returns up to 1000 at a time, to get more, set offset as the starting position to fetch. + + project is slug of your project. (Required) + status can be 'registered', 'completed', 'skipped', 'sent_back', 'approved', 'customer_sent_back', 'customer_approved'. (Optional) + tags is a list of tag. (Optional) + offset is the starting position number to fetch. (Optional) + limit is the max number to fetch. (Optional) + """ + endpoint = "tasks/video/classification" + params = {"project": project} + if status: + params["status"] = status + if tags: + params["tags"] = tags + if task_name: + params["taskName"] = task_name + if offset: + params["offset"] = offset + if limit: + params["limit"] = limit + return self.api.get_request(endpoint, params=params) + def get_task_id_name_map( self, project: str, offset: int = None, @@ -450,6 +483,56 @@ def update_task( payload["tags"] = tags return self.api.put_request(endpoint, payload=payload) + def update_image_classification_task( + self, + task_id: str, + status: str = None, + attributes: list = [], + tags: list = [], + ) -> str: + """ + Create a single image classification task. + + task_id is an id of the task. (Required) + status can be 'registered', 'completed', 'skipped', 'sent_back', 'approved', 'customer_sent_back', 'customer_approved'. (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) + """ + endpoint = "tasks/image/classification/" + task_id + payload = {} + if status: + payload["status"] = status + if attributes: + payload["attributes"] = attributes + if tags: + payload["tags"] = tags + return self.api.put_request(endpoint, payload=payload) + + def update_video_classification_task( + self, + task_id: str, + status: str = None, + attributes: list = [], + tags: list = [], + ) -> str: + """ + Create a single video classification task. + + task_id is an id of the task. (Required) + status can be 'registered', 'completed', 'skipped', 'sent_back', 'approved', 'customer_sent_back', 'customer_approved'. (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) + """ + endpoint = "tasks/video/classification/" + task_id + payload = {} + if status: + payload["status"] = status + if attributes: + payload["attributes"] = attributes + if tags: + payload["tags"] = tags + return self.api.put_request(endpoint, payload=payload) + # Task Delete def delete_task(self, task_id: str) -> None: diff --git a/setup.py b/setup.py index dc25c76..8edd941 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name="fastlabel", - version="0.9.6", + version="0.9.7", author="eisuke-ueta", author_email="eisuke.ueta@fastlabel.ai", description="The official Python SDK for FastLabel API, the Data Platform for AI",