Skip to content

Commit d08e1ae

Browse files
authored
Merge pull request #51 from fastlabel/feature/add-labelme-format-converter
add video / image classification
2 parents a2f2315 + fc3624a commit d08e1ae

File tree

3 files changed

+135
-1
lines changed

3 files changed

+135
-1
lines changed

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ _If you are using FastLabel prototype, please install version 0.2.2._
1212
- [Image Classification](#image-classification)
1313
- [Multi Image](#multi-image)
1414
- [Video](#video)
15+
- [Video Classification](#video-classification)
1516
- [Common](#common)
1617
- [Annotation](#annotation)
1718
- [Project](#project)
@@ -234,6 +235,24 @@ Get tasks. (Up to 1000 tasks)
234235
tasks = client.get_image_classification_tasks(project="YOUR_PROJECT_SLUG")
235236
```
236237

238+
#### Update Tasks
239+
240+
Update a signle task.
241+
242+
```python
243+
task_id = client.update_image_classification_task(
244+
task_id="YOUR_TASK_ID",
245+
status="approved",
246+
tags=["tag1", "tag2"]
247+
attributes=[
248+
{
249+
"key": "attribute-key",
250+
"value": "attribute-value"
251+
}
252+
],
253+
)
254+
```
255+
237256
#### Response
238257

239258
Example of a single image classification task object
@@ -513,6 +532,38 @@ Example of a single image classification task object
513532
}
514533
```
515534

535+
### Video Classification
536+
537+
Supported following project types:
538+
539+
- Video - Classification (Single)
540+
541+
#### Get Tasks
542+
543+
Get tasks. (Up to 1000 tasks)
544+
545+
```python
546+
tasks = client.get_video_classification_tasks(project="YOUR_PROJECT_SLUG")
547+
```
548+
549+
#### Update Tasks
550+
551+
Update a signle task.
552+
553+
```python
554+
task_id = client.update_video_classification_task(
555+
task_id="YOUR_TASK_ID",
556+
status="approved",
557+
tags=["tag1", "tag2"]
558+
attributes=[
559+
{
560+
"key": "attribute-key",
561+
"value": "attribute-value"
562+
}
563+
],
564+
)
565+
```
566+
516567
### Common
517568

518569
APIs for update and delete are same over all tasks.

fastlabel/__init__.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,39 @@ def get_video_tasks(
247247
params["limit"] = limit
248248
return self.api.get_request(endpoint, params=params)
249249

250+
def get_video_classification_tasks(
251+
self,
252+
project: str,
253+
status: str = None,
254+
tags: list = [],
255+
task_name: str = None,
256+
offset: int = None,
257+
limit: int = 100,
258+
) -> list:
259+
"""
260+
Returns a list of video classification tasks.
261+
Returns up to 1000 at a time, to get more, set offset as the starting position to fetch.
262+
263+
project is slug of your project. (Required)
264+
status can be 'registered', 'completed', 'skipped', 'sent_back', 'approved', 'customer_sent_back', 'customer_approved'. (Optional)
265+
tags is a list of tag. (Optional)
266+
offset is the starting position number to fetch. (Optional)
267+
limit is the max number to fetch. (Optional)
268+
"""
269+
endpoint = "tasks/video/classification"
270+
params = {"project": project}
271+
if status:
272+
params["status"] = status
273+
if tags:
274+
params["tags"] = tags
275+
if task_name:
276+
params["taskName"] = task_name
277+
if offset:
278+
params["offset"] = offset
279+
if limit:
280+
params["limit"] = limit
281+
return self.api.get_request(endpoint, params=params)
282+
250283
def get_task_id_name_map(
251284
self, project: str,
252285
offset: int = None,
@@ -450,6 +483,56 @@ def update_task(
450483
payload["tags"] = tags
451484
return self.api.put_request(endpoint, payload=payload)
452485

486+
def update_image_classification_task(
487+
self,
488+
task_id: str,
489+
status: str = None,
490+
attributes: list = [],
491+
tags: list = [],
492+
) -> str:
493+
"""
494+
Create a single image classification task.
495+
496+
task_id is an id of the task. (Required)
497+
status can be 'registered', 'completed', 'skipped', 'sent_back', 'approved', 'customer_sent_back', 'customer_approved'. (Optional)
498+
attributes is a list of attribute to be set in advance. (Optional)
499+
tags is a list of tag to be set in advance. (Optional)
500+
"""
501+
endpoint = "tasks/image/classification/" + task_id
502+
payload = {}
503+
if status:
504+
payload["status"] = status
505+
if attributes:
506+
payload["attributes"] = attributes
507+
if tags:
508+
payload["tags"] = tags
509+
return self.api.put_request(endpoint, payload=payload)
510+
511+
def update_video_classification_task(
512+
self,
513+
task_id: str,
514+
status: str = None,
515+
attributes: list = [],
516+
tags: list = [],
517+
) -> str:
518+
"""
519+
Create a single video classification task.
520+
521+
task_id is an id of the task. (Required)
522+
status can be 'registered', 'completed', 'skipped', 'sent_back', 'approved', 'customer_sent_back', 'customer_approved'. (Optional)
523+
attributes is a list of attribute to be set in advance. (Optional)
524+
tags is a list of tag to be set in advance. (Optional)
525+
"""
526+
endpoint = "tasks/video/classification/" + task_id
527+
payload = {}
528+
if status:
529+
payload["status"] = status
530+
if attributes:
531+
payload["attributes"] = attributes
532+
if tags:
533+
payload["tags"] = tags
534+
return self.api.put_request(endpoint, payload=payload)
535+
453536
# Task Delete
454537

455538
def delete_task(self, task_id: str) -> None:

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.6",
11+
version="0.9.7",
1212
author="eisuke-ueta",
1313
author_email="[email protected]",
1414
description="The official Python SDK for FastLabel API, the Data Platform for AI",

0 commit comments

Comments
 (0)