fastlabel 0.19.10
The official Python SDK for FastLabel API, the Data Platform for AI
Requires Python: >=3.8

# FastLabel Python SDK

## Table of Contents

- [Installation](#installation)
- [Usage](#usage)
  - [Limitation](#limitation)
- [Task](#task)
  - [Image](#image)
  - [Image Classification](#image-classification)
  - [Multi Image Classification](#multi-image-classification)
  - [Sequential Image](#sequential-image)
  - [Video](#video)
  - [Video Classification](#video-classification)
  - [Text](#text)
  - [Text Classification](#text-classification)
  - [Audio](#audio)
  - [Audio Classification](#audio-classification)
  - [PCD](#pcd)
  - [Sequential PCD](#sequential-pcd)
  - [DICOM](#dicom)
  - [Robotics](#robotics)
  - [Common](#common)
- [Appendix](#appendix)
- [Annotation](#annotation)
- [Metadata](#metadata)
- [Project](#project)
- [Dataset](#dataset)
- [Converter](#converter)
  - [FastLabel To COCO](#fastlabel-to-coco)
  - [FastLabel To YOLO](#fastlabel-to-yolo)
  - [FastLabel To Pascal VOC](#fastlabel-to-pascal-voc)
  - [FastLabel To labelme](#fastlabel-to-labelme)
  - [FastLabel To Segmentation](#fastlabel-to-segmentation)
  - [COCO To FastLabel](#coco-to-fastlabel)
  - [YOLO To FastLabel](#yolo-to-fastlabel)
  - [Pascal VOC To FastLabel](#pascal-voc-to-fastlabel)
  - [labelme To FastLabel](#labelme-to-fastlabel)
  - [Mask To FastLabel Segmentation Points](#mask-to-fastlabel-segmentation-points)
- [Model](#model)
- [API Docs](#api-docs)

## Installation

```bash
pip install --upgrade fastlabel
```

> Python version 3.8 or greater is required

## Usage

Configure API Key in environment variable.

```bash
export FASTLABEL_ACCESS_TOKEN="YOUR_ACCESS_TOKEN"
```

Initialize fastlabel client.

```python
import fastlabel
client = fastlabel.Client()
```

Or initialize with API Key directly.

```python
import fastlabel
client = fastlabel.Client("YOUR_ACCESS_TOKEN")
```

### Limitation

API is allowed to call 10000 times per 10 minutes. If you create/delete a large size of tasks, please wait a second for every requests.

## Task

### Image

Supported following project types:

- Image - Bounding Box
- Image - Polygon
- Image - Keypoint
- Image - Line
- Image - Segmentation
- Image - Pose Estimation
- Image - All

#### Create Task

Create a new task.

```python
task_id = client.create_image_task(
    project="YOUR_PROJECT_SLUG",
    name="sample.jpg",
    file_path="./sample.jpg"
)
```

Create a new task with pre-defined annotations and metadatas. (Class and metadata should be configured on your project in advance)

```python
task_id = client.create_image_task(
    project="YOUR_PROJECT_SLUG",
    name="sample.jpg",
    file_path="./sample.jpg",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    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
        ]
    }],
    metadatas=[  # (optional) pre-defined metadata key-value pairs
        {
            "key": "metadata_key",
            "value": "metadata_value"
        }
    ]
)
```

> Check [examples/create_image_task.py](/examples/create_image_task.py).

##### Limitation

- 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="<integrated-storage-dir>/sample.jpg",
    storage_type="gcp",
)
```

Create a new task with pre-defined annotations and metadatas. (Class and metadata should be configured on your project in advance)

```python
task_id = client.create_integrated_image_task(
    project="YOUR_PROJECT_SLUG",
    file_path="<integrated-storage-dir>/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
        ]
    }],
    metadatas=[  # (optional) pre-defined metadata key-value pairs
        {
            "key": "metadata_key",
            "value": "some_value"
        }
    ]
)
```

##### Limitation

- You can upload up to a size of 20 MB.

#### Find Task

Find a single task.

```python
task = client.find_image_task(task_id="YOUR_TASK_ID")
```

Find a single task by name.

```python
tasks = client.find_image_task_by_name(project="YOUR_PROJECT_SLUG", task_name="YOUR_TASK_NAME")
```

#### Get Tasks

Get tasks. (Up to 1000 tasks)

```python
tasks = client.get_image_tasks(project="YOUR_PROJECT_SLUG")
```

- Filter and Get tasks. (Up to 1000 tasks)

```python
tasks = client.get_image_tasks(
    project="YOUR_PROJECT_SLUG",
    status="approved", # status can be 'pending', 'registered', 'completed', 'skipped', 'reviewed' 'sent_back', 'approved', 'declined'
    tags=["tag1", "tag2"] # up to 10 tags
)
```

Get a large size of tasks. (Over 1000 tasks)

```python
import time

# Iterate pages until new tasks are empty.
all_tasks = []
offset = None
while True:
    time.sleep(1)

    tasks = client.get_image_tasks(project="YOUR_PROJECT_SLUG", offset=offset)
    all_tasks.extend(tasks)

    if len(tasks) > 0:
        offset = len(all_tasks)  # Set the offset
    else:
        break
```

> Please wait a second before sending another requests!

#### Update Tasks

Update a single task.

```python
task_id = client.update_image_task(
    task_id="YOUR_TASK_ID",
    status="approved",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    assignee="USER_SLUG",
    tags=["tag1", "tag2"],
    annotations=[
        {
            "type": "bbox",
            "value": "cat"
            "attributes": [
                { "key": "kind", "value": "Scottish field" }
            ],
            "points": [
                100,  # top-left x
                100,  # top-left y
                200,  # bottom-right x
                200   # bottom-right y
            ]
        }
    ],
    # pass annotation indexes to update
    relations=[
      {
        "startIndex": 1,
        "endIndex": 0,
      },
      {
        "startIndex": 2,
        "endIndex": 0
      }
    ],
    metadatas=[  # (optional) metadata key-value pairs (metadata should be configured on your project in advance)
        {
            "key": "metadata_key",
            "value": "metadata_value"
        }
    ]
)
```

#### Response

Example of a single image task object

```python
{
    "id": "YOUR_TASK_ID",
    "name": "cat.jpg",
    "width": 100,   # image width
    "height": 100,  # image height
    "url": "YOUR_TASK_URL",
    "status": "registered",
    "externalStatus": "registered",
    "priority": 10,
    "tags": [],
    "assignee": "ASSIGNEE_NAME",
    "reviewer": "REVIEWER_NAME",
    "externalAssignee": "EXTERNAL_ASSIGNEE_NAME",
    "externalReviewer": "EXTERNAL_REVIEWER_NAME",
    "annotations": [
        {
            "attributes": [
                { "key": "kind", "name": "Kind", "type": "text", "value": "Scottish field" }
            ],
            "color": "#b36d18",
            "points": [
                100,  # top-left x
                100,  # top-left y
                200,  # bottom-right x
                200   # bottom-right y
            ],
            "rotation": 0,
            "title": "Cat",
            "type": "bbox",
            "value": "cat"
        }
    ],
    "createdAt": "2021-02-22T11:25:27.158Z",
    "updatedAt": "2021-02-22T11:25:27.158Z"
}
```

Example when the project type is Image - Pose Estimation

```python
{
    "id": "YOUR_TASK_ID",
    "name": "person.jpg",
    "width": 255,   # image width
    "height": 255,  # image height
    "url": "YOUR_TASK_URL",
    "status": "registered",
    "externalStatus": "registered",
    "priority": 10,
    "tags": [],
    "assignee": "ASSIGNEE_NAME",
    "reviewer": "REVIEWER_NAME",
    "externalAssignee": "EXTERNAL_ASSIGNEE_NAME",
    "externalReviewer": "EXTERNAL_REVIEWER_NAME",
    "annotations":[
       {
          "type":"pose_estimation",
          "title":"jesture",
          "value":"jesture",
          "color":"#10c414",
          "attributes": [],
          "keypoints":[
             {
                "name":"頭",
                "key":"head",
                "value":[
                   102.59, # x
                   23.04,  # y
                   1       # 0:invisible, 1:visible
                ],
                "edges":[
                   "right_shoulder",
                   "left_shoulder"
                ]
             },
             {
                "name":"右肩",
                "key":"right_shoulder",
                "value":[
                   186.69,
                   114.11,
                   1
                ],
                "edges":[
                   "head"
                ]
             },
             {
                "name":"左肩",
                "key":"left_shoulder",
                "value":[
                   37.23,
                   109.29,
                   1
                ],
                "edges":[
                   "head"
                ]
             }
          ]
       }
    ],
    "createdAt": "2021-02-22T11:25:27.158Z",
    "updatedAt": "2021-02-22T11:25:27.158Z"
}
```

#### Export Image With Annotations

Get tasks and export images with annotations.
Only support the following image extension.

- jpeg
- jpg
- png
- tif
- tiff
- bmp

```python
tasks = client.get_image_tasks(project="YOUR_PROJECT_SLUG")
client.export_image_with_annotations(
    tasks=tasks, image_dir="IMAGE_DIR", output_dir="OUTPUT_DIR"
)
```

#### Integrate Task

This function is alpha version. It is subject to major changes in the future.

Integration is possible only when tasks are registered from the objects divided by the dataset.
Only bbox and polygon annotation types are supported.

In the case of a task divided under the following conditions.

- Dataset slug: `image`
- Object name: `cat.jpg`
- Split count: `3×3`

Objects are registered in the data set in the following form.

- image/cat/1.jpg
- image/cat/2.jpg
- image/cat/3.jpg
- (omit)
- image/cat/9.jpg

The annotations at the edges of the image are combined. However, annotations with a maximum length of 300px may not work.

In this case, SPLIT_IMAGE_TASK_NAME_PREFIX specifies `image/cat`.

```python
task = client.find_integrated_image_task_by_prefix(
    project="YOUR_PROJECT_SLUG",
    prefix="SPLIT_IMAGE_TASK_NAME_PREFIX",
)
```

##### Response

Example of a integrated image task object

```python
{
    'name': 'image/cat.jpg',
    "annotations": [
        {
            "attributes": [],
            "color": "#b36d18",
            "confidenceScore"; -1,
            "keypoints": [],
            "points": [200,200,300,400],
            "rotation": 0,
            "title": "Bird",
            "type": "polygon",
            "value": "bird"
        }
    ],
}
```

### Image Classification

Supported following project types:

- Image - Classification

#### Create Task

Create a new task.

```python
task_id = client.create_image_classification_task(
    project="YOUR_PROJECT_SLUG",
    name="sample.jpg",
    file_path="./sample.jpg",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    attributes=[
        {
            "key": "attribute-key",
            "value": "attribute-value"
        }
    ],
)
```

##### Limitation

- 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="<integrated-storage-dir>/sample.jpg",
    storage_type="gcp",
)
```

#### Find Task

Find a single task.

```python
task = client.find_image_classification_task(task_id="YOUR_TASK_ID")
```

Find a single task by name.

```python
tasks = client.find_image_classification_task_by_name(project="YOUR_PROJECT_SLUG", task_name="YOUR_TASK_NAME")
```

#### Get Tasks

Get tasks. (Up to 1000 tasks)

```python
tasks = client.get_image_classification_tasks(project="YOUR_PROJECT_SLUG")
```

#### Update Tasks

Update a single task.

```python
task_id = client.update_image_classification_task(
    task_id="YOUR_TASK_ID",
    status="approved",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    assignee="USER_SLUG",
    tags=["tag1", "tag2"],
    attributes=[
        {
            "key": "attribute-key",
            "value": "attribute-value"
        }
    ],
)
```

#### Response

Example of a single image classification task object

```python
{
    "id": "YOUR_TASK_ID",
    "name": "cat.jpg",
    "width": 100,   # image width
    "height": 100,  # image height
    "url": "YOUR_TASK_URL",
    "status": "registered",
    "externalStatus": "registered",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    "tags": [],
    "assignee": "ASSIGNEE_NAME",
    "reviewer": "REVIEWER_NAME",
    "externalAssignee": "EXTERNAL_ASSIGNEE_NAME",
    "externalReviewer": "EXTERNAL_REVIEWER_NAME",
    "attributes": [
        {
            "key": "kind",
            "name": "Kind",
            "type": "text",
            "value": "Scottish field"
        }
    ],
    "createdAt": "2021-02-22T11:25:27.158Z",
    "updatedAt": "2021-02-22T11:25:27.158Z"
}
```

### Multi Image Classification

Supported following project types:

- Multi Image - Classification

#### Create Task

Create a new task.

```python
task = client.create_multi_image_classification_task(
    project="YOUR_PROJECT_SLUG",
    name="sample",
    folder_path="./sample",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    attributes=[
        {
            "type": "text",
            "key": "attribute-key",
            "value": "attribute-value"
        }
    ]
)
```

##### Limitation

- You can upload up to a size of 20 MB.
- You can upload up to a total size of 2 GB.
- You can upload up to 6 files in total.

#### Find Task

Find a single task.

```python
task = client.find_multi_image_classification_task(task_id="YOUR_TASK_ID")
```

Find a single task by name.

```python
tasks = client.find_multi_image_classification_task_by_name(project="YOUR_PROJECT_SLUG", task_name="YOUR_TASK_NAME")
```

#### Get Tasks

Get tasks.

```python
tasks = client.get_multi_image_classification_tasks(project="YOUR_PROJECT_SLUG")
```

#### Update Task

Update a single task.

```python
task_id = client.update_multi_image_classification_task(
    task_id="YOUR_TASK_ID",
    status="approved",
    assignee="USER_SLUG",
    tags=["tag1", "tag2"],
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    attributes=[
        {
            "type": "text",
            "key": "attribute-key",
            "value": "attribute-value"
        }
    ]
)
```

#### Response

Example of a single task object

```python
{
    "id": "YOUR_TASK_ID",
    "name": "sample",
    "contents": [
        {
            "name": "content-name-1",
            "url": "content-url-1",
            "width": 100,
            "height": 100,
        },
        {
            "name": "content-name-2",
            "url": "content-url-2",
            "width": 100,
            "height": 100,
        }
    ],
    "status": "registered",
    "externalStatus": "registered",
    "priority": 10,
    "tags": [],
    "assignee": "ASSIGNEE_NAME",
    "reviewer": "REVIEWER_NAME",
    "externalAssignee": "EXTERNAL_ASSIGNEE_NAME",
    "externalReviewer": "EXTERNAL_REVIEWER_NAME",
    "attributes": [
        {
            "type": "text",
            "key": "attribute-key-1",
            "value": "attribute-value-1"
        },
        {
            "type": "text",
            "key": "attribute-key-2",
            "value": "attribute-value-2"
        }
    ],
    "createdAt": "2021-02-22T11:25:27.158Z",
    "updatedAt": "2021-02-22T11:25:27.158Z"
}
```

### Sequential Image

Supported following project types:

- Sequential Image - Bounding Box
- Sequential Image - Polygon
- Sequential Image - Keypoint
- Sequential Image - Line
- Sequential Image - Segmentation

#### Create Task

Create a new task.

```python
task = client.create_sequential_image_task(
    project="YOUR_PROJECT_SLUG",
    name="sample",
    folder_path="./sample",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    annotations=[{
        "type": "segmentation",
        "value": "annotation-value",
        "attributes": [
            {
                "key": "attribute-key",
                "value": "attribute-value"
            }
        ],
        "content": "01.jpg",
        "points": [[[
            100,
            100,
            300,
            100,
            300,
            300,
            100,
            300,
            100,
            100
        ]]] # clockwise rotation
    }],
    metadatas=[  # (optional) pre-defined metadata key-value pairs
        {
            "key": "metadata_key",
            "value": "some_value"
        }
    ]
)
```

##### Limitation

- You can upload up to a size of 20 MB.
- You can upload up to a total size of 512 MB.
- You can upload up to 250 files in total.

#### Find Task

Find a single task.

```python
task = client.find_sequential_image_task(task_id="YOUR_TASK_ID")
```

Find a single task by name.

```python
tasks = client.find_sequential_image_task_by_name(project="YOUR_PROJECT_SLUG", task_name="YOUR_TASK_NAME")
```

#### Get Tasks

Get tasks.

```python
tasks = client.get_sequential_image_tasks(project="YOUR_PROJECT_SLUG")
```

#### Update Task

Update a single task.

```python
task_id = client.update_sequential_image_task(
    task_id="YOUR_TASK_ID",
    status="approved",
    assignee="USER_SLUG",
    tags=["tag1", "tag2"],
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    annotations=[
        {
            "type": "bbox",
            "value": "cat",
            "content": "cat1.jpg",
            "attributes": [
                { "key": "key", "value": "value1" }
            ],
            "points": [990, 560, 980, 550]
        }
    ],
    metadatas=[  # (optional) metadata key-value pairs
        {
            "key": "metadata_key",
            "value": "metadata_value"
        }
    ]
)
```

#### Response

Example of a single task object

```python
{
    "id": "YOUR_TASK_ID",
    "name": "cat.jpg",
    "contents": [
        {
            "name": "content-name",
            "url": "content-url",
            "width": 100,
            "height": 100,
        }
    ],
    "status": "registered",
    "externalStatus": "registered",
    "priority": 10,
    "tags": [],
    "assignee": "ASSIGNEE_NAME",
    "reviewer": "REVIEWER_NAME",
    "externalAssignee": "EXTERNAL_ASSIGNEE_NAME",
    "externalReviewer": "EXTERNAL_REVIEWER_NAME",
    "annotations": [
        {
            "content": "content-name"
            "attributes": [],
            "color": "#b36d18",
            "points": [[[
                100,
                100,
                300,
                100,
                300,
                300,
                100,
                300,
                100,
                100
            ]]]
            "title": "Cat",
            "type": "bbox",
            "value": "cat"
        }
    ],
    "createdAt": "2021-02-22T11:25:27.158Z",
    "updatedAt": "2021-02-22T11:25:27.158Z"
}
```

### Video

Supported following project types:

- Video - Bounding Box
- Video - Keypoint
- Video - Line

#### Create Task

Create a new task.

```python
task_id = client.create_video_task(
    project="YOUR_PROJECT_SLUG",
    name="sample.mp4",
    file_path="./sample.mp4"
)
```

Create a new task with pre-defined annotations and metadatas. (Class and metadata should be configured on your project in advance)

```python
task_id = client.create_video_task(
    project="YOUR_PROJECT_SLUG",
    name="sample.mp4",
    file_path="./sample.mp4",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    annotations=[{
        "type": "bbox",
        "value": "person",
        "points": {
            "1": {  # number of frame
                "value": [
                    100,  # top-left x
                    100,  # top-left y
                    200,  # bottom-right x
                    200   # bottom-right y
                ],
                # Make sure to set `autogenerated` False for the first and last frame. "1" and "3" frames in this case.
                # Otherwise, annotation is auto-completed for rest of frames when you edit.
                "autogenerated": False
            },
            "2": {
                "value": [
                    110,
                    110,
                    220,
                    220
                ],
                "autogenerated": True
            },
            "3": {
                "value": [
                    120,
                    120,
                    240,
                    240
                ],
                "autogenerated": False
            }
        }
    }],
    metadatas=[  # (optional) pre-defined metadata key-value pairs
        {
            "key": "metadata_key",
            "value": "metadata_value"
        }
    ]
)
```

##### Limitation

- You can upload up to a size of 250 MB.
- You can upload only videos with H.264 encoding.
- You can upload only MP4 file format.

#### Find Task

Find a single task.

```python
task = client.find_video_task(task_id="YOUR_TASK_ID")
```

Find a single task by name.

```python
tasks = client.find_video_task_by_name(project="YOUR_PROJECT_SLUG", task_name="YOUR_TASK_NAME")
```

#### Get Tasks

Get tasks. (Up to 10 tasks)

```python
tasks = client.get_video_tasks(project="YOUR_PROJECT_SLUG")
```

#### Update Task

Update a single task.

```python
task_id = client.update_video_task(
    task_id="YOUR_TASK_ID",
    status="approved",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    assignee="USER_SLUG",
    tags=["tag1", "tag2"],
    annotations=[{
        "type": "bbox",
        "value": "bird",
        "points": {
            "1": {
                "value": [
                    100,
                    100,
                    200,
                    200
                ],
                "autogenerated": False
            },
            "2": {
                "value": [
                    110,
                    110,
                    220,
                    220
                ],
                "autogenerated": True
            },
            "3": {
                "value": [
                    120,
                    120,
                    240,
                    240
                ],
                "autogenerated": False
            }
        }
    }],
    metadatas=[  # (optional) metadata key-value pairs
        {
            "key": "metadata_key",
            "value": "metadata_value"
        }
    ]
)
```

#### Integrate Video

This function is alpha version. It is subject to major changes in the future.

Integration is possible only when tasks are registered from the objects divided by the dataset.

In the case of a task divided under the following conditions.

- Dataset slug: `video`
- Object name: `cat.mp4`
- Split count: `3`

Objects are registered in the data set in the following form.

- video/cat/1.mp4
- video/cat/2.mp4
- video/cat/3.mp4

In this case, SPLIT_VIDEO_TASK_NAME_PREFIX specifies `video/cat`.

```python
task = client.find_integrated_video_task_by_prefix(
    project="YOUR_PROJECT_SLUG",
    prefix="SPLIT_VIDEO_TASK_NAME_PREFIX",
)
```

#### Response

Example of a single vide task object

```python
{
    "id": "YOUR_TASK_ID",
    "name": "cat.jpg",
    "width": 100,   # image width
    "height": 100,  # image height
    "fps": 30.0,    # frame per seconds
    "frameCount": 480,  # total frame count of video
    "duration": 16.0,   # total duration of video
    "url": "YOUR_TASK_URL",
    "status": "registered",
    "externalStatus": "registered",
    "priority": 10,
    "tags": [],
    "assignee": "ASSIGNEE_NAME",
    "reviewer": "REVIEWER_NAME",
    "externalAssignee": "EXTERNAL_ASSIGNEE_NAME",
    "externalReviewer": "EXTERNAL_REVIEWER_NAME",
    "annotations": [
        {
            "attributes": [],
            "color": "#b36d18",
            "points": {
                "1": {  # number of frame
                    "value": [
                        100,  # top-left x
                        100,  # top-left y
                        200,  # bottom-right x
                        200   # bottom-right y
                    ],
                    "autogenerated": False  # False when annotated manually. True when auto-generated by system.
                },
                "2": {
                    "value": [
                        110,
                        110,
                        220,
                        220
                    ],
                    "autogenerated": True
                },
                "3": {
                    "value": [
                        120,
                        120,
                        240,
                        240
                    ],
                    "autogenerated": False
                }
            },
            "title": "Cat",
            "type": "bbox",
            "value": "cat"
        }
    ],
    "createdAt": "2021-02-22T11:25:27.158Z",
    "updatedAt": "2021-02-22T11:25:27.158Z"
}
```

### Video Classification

Supported following project types:

- Video - Classification (Single)

#### Create Task

Create a new task.

```python
task_id = client.create_video_classification_task(
    project="YOUR_PROJECT_SLUG",
    name="sample.mp4",
    file_path="./sample.mp4",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    attributes=[
        {
            "key": "attribute-key",
            "value": "attribute-value"
        }
    ],
)
```

##### Limitation

- You can upload up to a size of 250 MB.

#### Find Task

Find a single task.

```python
task = client.find_video_classification_task(task_id="YOUR_TASK_ID")
```

Find a single task by name.

```python
tasks = client.find_video_classification_task_by_name(project="YOUR_PROJECT_SLUG", task_name="YOUR_TASK_NAME")
```

#### Get Tasks

Get tasks. (Up to 1000 tasks)

```python
tasks = client.get_video_classification_tasks(project="YOUR_PROJECT_SLUG")
```

#### Update Tasks

Update a single task.

```python
task_id = client.update_video_classification_task(
    task_id="YOUR_TASK_ID",
    status="approved",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    assignee="USER_SLUG",
    tags=["tag1", "tag2"],
    attributes=[
        {
            "key": "attribute-key",
            "value": "attribute-value"
        }
    ],
)
```

### Text

Supported following project types:

- Text - NER

#### Create Task

Create a new task.

```python
task_id = client.create_text_task(
    project="YOUR_PROJECT_SLUG",
    name="sample.txt",
    file_path="./sample.txt"
)
```

Create a new task with pre-defined annotations and metadatas. (Class and metadata should be configured on your project in advance)

```python
task_id = client.create_text_task(
    project="YOUR_PROJECT_SLUG",
    name="sample.txt",
    file_path="./sample.txt",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    annotations=[{
        "type": "ner",
        "value": "person",
        "start": 0,
        "end": 10,
        "text": "1234567890"
    }],
    metadatas=[  # (optional) pre-defined metadata key-value pairs
        {
            "key": "metadata_key",
            "value": "metadata_value"
        }
    ]
)
```

##### Limitation

- You can upload up to a size of 2 MB.

#### Find Task

Find a single task.

```python
task = client.find_text_task(task_id="YOUR_TASK_ID")
```

Find a single task by name.

```python
tasks = client.find_text_task_by_name(project="YOUR_PROJECT_SLUG", task_name="YOUR_TASK_NAME")
```

#### Get Tasks

Get tasks. (Up to 10 tasks)

```python
tasks = client.get_text_tasks(project="YOUR_PROJECT_SLUG")
```

#### Update Task

Update a single task.

```python
task_id = client.update_text_task(
    task_id="YOUR_TASK_ID",
    status="approved",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    assignee="USER_SLUG",
    tags=["tag1", "tag2"],
    annotations=[{
        "type": "bbox",
        "value": "bird",
        "start": 0,
        "end": 10,
        "text": "0123456789"
    }],
    metadatas=[  # (optional) metadata key-value pairs
        {
            "key": "metadata_key",
            "value": "metadata_value"
        }
    ]
)
```

#### Response

Example of a single text task object

```python
{
    "id": "YOUR_TASK_ID",
    "name": "cat.txt",
    "url": "YOUR_TASK_URL",
    "status": "registered",
    "externalStatus": "registered",
    "priority": 10,
    "tags": [],
    "assignee": "ASSIGNEE_NAME",
    "reviewer": "REVIEWER_NAME",
    "externalAssignee": "EXTERNAL_ASSIGNEE_NAME",
    "externalReviewer": "EXTERNAL_REVIEWER_NAME",
    "annotations": [
        {
            "attributes": [],
            "color": "#b36d18",
            "text": "0123456789",
            "start": 0,
            "end": 10,
            "title": "Cat",
            "type": "ner",
            "value": "cat"
        }
    ],
    "createdAt": "2021-02-22T11:25:27.158Z",
    "updatedAt": "2021-02-22T11:25:27.158Z"
}
```

### Text Classification

Supported following project types:

- Text - Classification (Single)

#### Create Task

Create a new task.

```python
task_id = client.create_text_classification_task(
    project="YOUR_PROJECT_SLUG",
    name="sample.txt",
    file_path="./sample.txt",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    attributes=[
        {
            "key": "attribute-key",
            "value": "attribute-value"
        }
    ],
)
```

##### Limitation

- You can upload up to a size of 2 MB.

#### Find Task

Find a single task.

```python
task = client.find_text_classification_task(task_id="YOUR_TASK_ID")
```

Find a single task by name.

```python
tasks = client.find_text_classification_task_by_name(project="YOUR_PROJECT_SLUG", task_name="YOUR_TASK_NAME")
```

#### Get Tasks

Get tasks. (Up to 1000 tasks)

```python
tasks = client.get_text_classification_tasks(project="YOUR_PROJECT_SLUG")
```

#### Update Tasks

Update a single task.

```python
task_id = client.update_text_classification_task(
    task_id="YOUR_TASK_ID",
    status="approved",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    assignee="USER_SLUG",
    tags=["tag1", "tag2"],
    attributes=[
        {
            "key": "attribute-key",
            "value": "attribute-value"
        }
    ],
)
```

### Audio

Supported following project types:

- Audio - Segmentation

#### Create Task

Create a new task.

```python
task_id = client.create_audio_task(
    project="YOUR_PROJECT_SLUG",
    name="sample.mp3",
    file_path="./sample.mp3"
)
```

Create a new task with pre-defined annotations and metadatas. (Class and metadata should be configured on your project in advance)

```python
task_id = client.create_audio_task(
    project="YOUR_PROJECT_SLUG",
    name="sample.mp3",
    file_path="./sample.mp3",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    annotations=[{
        "type": "segmentation",
        "value": "person",
        "start": 0.4,
        "end": 0.5
    }],
    metadatas=[  # (optional) pre-defined metadata key-value pairs
        {
            "key": "metadata_key",
            "value": "metadata_value"
        }
    ]
)
```

##### Limitation

- You can upload up to a size of 120 MB.

#### Find Task

Find a single task.

```python
task = client.find_audio_task(task_id="YOUR_TASK_ID")
```

Find a single task by name.

```python
tasks = client.find_audio_task_by_name(project="YOUR_PROJECT_SLUG", task_name="YOUR_TASK_NAME")
```

#### Get Tasks

Get tasks. (Up to 10 tasks)

```python
tasks = client.get_audio_tasks(project="YOUR_PROJECT_SLUG")
```

#### Update Task

Update a single task.

```python
task_id = client.update_audio_task(
    task_id="YOUR_TASK_ID",
    status="approved",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    assignee="USER_SLUG",
    tags=["tag1", "tag2"],
    annotations=[{
        "type": "segmentation",
        "value": "bird",
        "start": 0.4,
        "end": 0.5
    }],
    metadatas=[  # (optional) metadata key-value pairs
        {
            "key": "metadata_key",
            "value": "metadata_value"
        }
    ]
)
```

#### Response

Example of a single audio task object

```python
{
    "id": "YOUR_TASK_ID",
    "name": "cat.mp3",
    "url": "YOUR_TASK_URL",
    "status": "registered",
    "externalStatus": "registered",
    "priority": 10,
    "tags": [],
    "assignee": "ASSIGNEE_NAME",
    "reviewer": "REVIEWER_NAME",
    "externalAssignee": "EXTERNAL_ASSIGNEE_NAME",
    "externalReviewer": "EXTERNAL_REVIEWER_NAME",
    "annotations": [
        {
            "attributes": [],
            "color": "#b36d18",
            "start": 0.4,
            "end": 0.5,
            "title": "Bird",
            "type": "segmentation",
            "value": "bird"
        }
    ],
    "createdAt": "2021-02-22T11:25:27.158Z",
    "updatedAt": "2021-02-22T11:25:27.158Z"
}
```

#### Integrate Task

This function is alpha version. It is subject to major changes in the future.

Integration is possible only when tasks are registered from the objects divided by the dataset.

In the case of a task divided under the following conditions.

- Dataset slug: `audio`
- Object name: `voice.mp3`
- Split count: `3`

Objects are registered in the data set in the following form.

- audio/voice/1.mp3
- audio/voice/2.mp3
- audio/voice/3.mp3

Annotations are combined when the end point specified in the annotation is the end time of the task and the start point of the next task is 0 seconds.

In this case, SPLIT_AUDIO_TASK_NAME_PREFIX specifies `audio/voice`.

```python
task = client.find_integrated_audio_task_by_prefix(
    project="YOUR_PROJECT_SLUG",
    prefix="SPLIT_AUDIO_TASK_NAME_PREFIX",
)
```

##### Response

Example of a integrated audio task object

```python
{
    'name': 'audio/voice.mp3',
    "annotations": [
        {
            "attributes": [],
            "color": "#b36d18",
            "start": 0.4,
            "end": 0.5,
            "title": "Bird",
            "type": "segmentation",
            "value": "bird"
        }
    ],
}
```

### Audio Classification

Supported following project types:

- Audio - Classification (Single)

#### Create Task

Create a new task.

```python
task_id = client.create_audio_classification_task(
    project="YOUR_PROJECT_SLUG",
    name="sample.mp3",
    file_path="./sample.mp3",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    attributes=[
        {
            "key": "attribute-key",
            "value": "attribute-value"
        }
    ],
)
```

##### Limitation

- You can upload up to a size of 120 MB.

#### Find Task

Find a single task.

```python
task = client.find_audio_classification_task(task_id="YOUR_TASK_ID")
```

Find a single task by name.

```python
tasks = client.find_audio_classification_task_by_name(project="YOUR_PROJECT_SLUG", task_name="YOUR_TASK_NAME")
```

#### Get Tasks

Get tasks. (Up to 1000 tasks)

```python
tasks = client.get_audio_classification_tasks(project="YOUR_PROJECT_SLUG")
```

#### Update Tasks

Update a single task.

```python
task_id = client.update_audio_classification_task(
    task_id="YOUR_TASK_ID",
    status="approved",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    assignee="USER_SLUG",
    tags=["tag1", "tag2"],
    attributes=[
        {
            "key": "attribute-key",
            "value": "attribute-value"
        }
    ],
)
```

### PCD

Supported following project types:

- PCD - Cuboid
- PCD - Segmentation

#### Create Task

Create a new task.

```python
task_id = client.create_pcd_task(
    project="YOUR_PROJECT_SLUG",
    name="sample.pcd",
    file_path="./sample.pcd"
)
```

Create a new task with pre-defined annotations and metadatas. (Class and metadata should be configured on your project in advance)

Annotation Type: cuboid

```python
task_id = client.create_pcd_task(
    project="YOUR_PROJECT_SLUG",
    name="sample.pcd",
    file_path="./sample.pcd",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    annotations=[
        {
            "type": "cuboid",
            "value": "car",
            "points": [ # For cuboid, it is a 9-digit number.
                1, # Coordinate X
                2, # Coordinate Y
                3, # Coordinate Z
                1, # Rotation x
                1, # Rotation Y
                1, # Rotation Z
                2, # Length X
                2, # Length Y
                2  # Length Z
            ],
        }
    ],
    metadatas=[  # (optional) pre-defined metadata key-value pairs
        {
            "key": "metadata_key",
            "value": "metadata_value"
        }
    ]
)
```

Annotation Type: segmentation

```python
task_id = client.create_pcd_task(
    project="YOUR_PROJECT_SLUG",
    name="sample.pcd",
    file_path="./sample.pcd",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    annotations=[
        {
            "type": "segmentation",
            "value": "car",
            "points": [1, 2, 3, 4, 5], # For segmentation, it is an arbitrary numeric array.
        }
    ],
)
```

##### Limitation

- You can upload up to a size of 30 MB.

#### Find Task

Find a single task.

```python
task = client.find_pcd_task(task_id="YOUR_TASK_ID")
```

Find a single task by name.

```python
tasks = client.find_pcd_task_by_name(project="YOUR_PROJECT_SLUG", task_name="YOUR_TASK_NAME")
```

#### Get Tasks

Get tasks. (Up to 1000 tasks)

```python
tasks = client.get_pcd_tasks(project="YOUR_PROJECT_SLUG")
```

#### Update Task

Update a single task.

```python
task_id = client.update_pcd_task(
    task_id="YOUR_TASK_ID",
    status="approved",
    priority=10, # (optional) none: 0, low: 10, medium: 20, high: 30
    assignee="USER_SLUG",
    tags=["tag1", "tag2"],
    annotations=[
        {
            "type": "cuboid",
            "value": "car",
            "points": [ # For cuboid, it is a 9-digit number.
                1, # Coordinate X
                2, # Coordinate Y
                3, # Coordinate Z
                1, # Rotation x
                1, # Rotation Y
                1, # Rotation Z
                2, # Length X
                2, # Length Y
                2  # Length Z
            ],
        }
    ],
    metadatas=[  # (optional) metadata key-value pairs
        {
            "key": "metadata_key",
            "value": "metadata_value"
        }
    ]
)
```

#### Response

Example of a single PCD task object

```python
{
    "id": "YOUR_TASK_ID",
    "name": "sample.pcd",
    "url": "YOUR_TASK_URL",
    "status": "registered",
    "externalStatus": "registered",
    "priority": 10,
    "tags": ["tag1", "tag2"],
    "assignee": "ASSIGNEE_NAME",
    "reviewer": "REVIEWER_NAME",
    "approver": "APPROVER_NAME",
    "externalAssignee": "EXTERNAL_ASSIGNEE_NAME",
    "externalReviewer": "EXTERNAL_REVIEWER_NAME",
    "externalApprover": "EXTERNAL_APPROVER_NAME",
    "annotations": [
        {
            "attributes": [],
            "color": "#b36d18",
            "title": "Car",
            "type": "segme