The official Python SDK for FastLabel API, the Data Platform for AI
Project description
FastLabel Python SDK
If you are using FastLabel prototype, please install version 0.2.2.
Installation
$ pip install --upgrade fastlabel
Python version 3.7 or greater is required
Usage
Configure API Key in environment variable.
export FASTLABEL_ACCESS_TOKEN="YOUR_ACCESS_TOKEN"
Initialize fastlabel client.
import fastlabel
client = fastlabel.Client()
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:
- Bounding Box
- Polygon
- Keypoint
- Line
- Segmentation
Create Task
- Create a new task.
task_id = client.create_task(
project="YOUR_PROJECT_SLUG",
name="sample.jpg",
file_path="./sample.jpg"
)
- Create a new task with pre-defined annotations. (Class should be configured on your project in advance)
task_id = client.create_task(
project="YOUR_PROJECT_SLUG",
name="sample.jpg",
file_path="./sample.jpg",
annotations=[{
"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
]
}]
)
Check examples/create_task.py.
Update Task
- Update a single task status and tags.
task_id = client.update_task(
task_id="YOUR_TASK_ID",
status="approved",
tags=["tag1", "tag2"]
)
Find Task
- Find a single task.
task = client.find_task(task_id="YOUR_TASK_ID")
Get Tasks
- Get tasks. (Up to 1000 tasks)
tasks = client.get_tasks(project="YOUR_PROJECT_SLUG")
- Filter and Get tasks. (Up to 1000 tasks)
tasks = client.get_tasks(
project="YOUR_PROJECT_SLUG",
status="approved", # status can be 'registered', 'in_progress', 'completed', 'skipped', 'in_review', 'send_backed', 'approved', 'customer_in_review', 'customer_send_backed', 'customer_approved'
tags=["tag1", "tag2"] # up to 10 tags
)
- Get a large size of tasks. (Over 1000 tasks)
import time
# Iterate pages until new tasks are empty.
all_tasks = []
offset = None
while True:
time.sleep(1)
tasks = client.get_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!
Delete Task
- Delete a single task.
client.delete_task(task_id="YOUR_TASK_ID")
Task Response
- Example of a single task object
{
"id": "YOUR_TASK_ID",
"name": "cat.jpg",
"url": "YOUR_TASK_URL",
"status": "registered",
"tags": [],
"annotations": [
{
"attributes": [
{ "key": "kind", "name": "猫の種類", "type": "text", "value": "三毛猫" }
],
"color": "#b36d18",
"points": [
100, # top-left x
100, # top-left y
200, # bottom-right x
200 # bottom-right y
],
"title": "Cat",
"type": "bbox",
"value": "cat"
}
],
"createdAt": "2021-02-22T11:25:27.158Z",
"updatedAt": "2021-02-22T11:25:27.158Z"
}
Multi Image
Supported following project types:
- Bounding Box
- Polygon
- Keypoint
- Line
- Segmentation
Create Task
- Create a new task.
task = client.create_multi_image_task(
project="YOUR_PROJECT_SLUG",
name="sample.jpg",
folder_path="./sample",
annotations=[{
"value": "annotation-value",
"attributes": [
{
"key": "attribute-key",
"value": "attribute-value"
}
],
"points": [[[
100,
100,
300,
100,
300,
300,
100,
300,
100,
100
]]] # clockwise rotation
}]
)
Update Task
- Same as image task.
Find Task
- Find a single task.
task = client.find_multi_image_task(task_id="YOUR_TASK_ID")
Get Tasks
- Get tasks.
tasks = client.get_multi_image_tasks(project="YOUR_PROJECT_SLUG")
Delete Task
- Same as image task.
Task Response
- Example of a single task object
{
"id": "YOUR_TASK_ID",
"name": "cat.jpg",
"contents": [
{
"name": "content-name",
"url": "content-url",
"width": "content-width",
"height": "content-height",
}
],
"status": "registered",
"tags": [],
"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"
}
API Docs
Check this for further information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fastlabel-0.4.0.tar.gz
(5.9 kB
view hashes)
Built Distribution
Close
Hashes for fastlabel-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb349ce0b6b1f2f12c24d694f8a4c603ea2c611421d14c0526057ca75e619d31 |
|
MD5 | 143f6f5773053ea719da4f7aea0d1c48 |
|
BLAKE2b-256 | d99c0c5ae68aac59709ab76870af0ed4ec00eda7508534e70968c92a501a9e8b |