Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
83 changes: 83 additions & 0 deletions fastlabel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down