Skip to content

Commit 6312ece

Browse files
authored
Merge pull request #39 from fastlabel/develop
Merge to main
2 parents a39f153 + aa0bc6e commit 6312ece

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,51 @@ task_id = client.create_video_task(
388388
)
389389
```
390390

391+
- Create a new task with pre-defined annotations. (Class should be configured on your project in advance)
392+
393+
```python
394+
task_id = client.create_video_task(
395+
project="YOUR_PROJECT_SLUG",
396+
name="sample.mp4",
397+
file_path="./sample.mp4",
398+
annotations=[{
399+
"type": "bbox",
400+
"value": "person",
401+
"points": {
402+
"1": { # number of frame
403+
"value": [
404+
100, # top-left x
405+
100, # top-left y
406+
200, # bottom-right x
407+
200 # bottom-right y
408+
],
409+
# Make sure to set `autogenerated` False for the first and last frame. "1" and "3" frames in this case.
410+
# Otherwise, annotation is auto-completed for rest of frames when you edit.
411+
"autogenerated": False
412+
},
413+
"2": {
414+
"value": [
415+
110,
416+
110,
417+
220,
418+
220
419+
],
420+
"autogenerated": True
421+
},
422+
"3": {
423+
"value": [
424+
120,
425+
120,
426+
240,
427+
240
428+
],
429+
"autogenerated": False
430+
}
431+
}
432+
}]
433+
)
434+
```
435+
391436
#### Find Task
392437

393438
- Find a single task.

fastlabel/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ def create_video_task(
393393
name: str,
394394
file_path: str,
395395
status: str = None,
396+
annotations: list = [],
396397
tags: list = [],
397398
) -> str:
398399
"""
@@ -402,6 +403,7 @@ def create_video_task(
402403
name is an unique identifier of task in your project. (Required)
403404
file_path is a path to data. Supported extensions are png, jpg, jpeg. (Required)
404405
status can be 'registered', 'in_progress', 'completed', 'skipped', 'in_review', 'send_backed', 'approved', 'customer_in_review', 'customer_send_backed', 'customer_approved'. (Optional)
406+
annotations is a list of annotation to be set in advance. (Optional)
405407
tags is a list of tag to be set in advance. (Optional)
406408
"""
407409
endpoint = "tasks/video"
@@ -412,6 +414,10 @@ def create_video_task(
412414
payload = {"project": project, "name": name, "file": file}
413415
if status:
414416
payload["status"] = status
417+
if annotations:
418+
for annotation in annotations:
419+
annotation["content"] = name
420+
payload["annotations"] = annotations
415421
if tags:
416422
payload["tags"] = tags
417423
return self.api.post_request(endpoint, payload=payload)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setuptools.setup(
1010
name="fastlabel",
11-
version="0.9.0",
11+
version="0.9.1",
1212
author="eisuke-ueta",
1313
author_email="eisuke.ueta@fastlabel.ai",
1414
description="The official Python SDK for FastLabel API, the Data Platform for AI",

0 commit comments

Comments
 (0)