Skip to content

Commit d1a84b7

Browse files
committed
impl integrated image task create api
1 parent 3abc9a6 commit d1a84b7

File tree

2 files changed

+98
-1
lines changed

2 files changed

+98
-1
lines changed

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,51 @@ task_id = client.create_image_task(
120120

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

123+
124+
#### Create Integrated Image Task
125+
126+
Create a new task by integrated image.
127+
(Project storage setting should be configured in advance.)
128+
129+
```python
130+
task_id = client.create_integrated_image_task(
131+
project="YOUR_PROJECT_SLUG",
132+
file_path="<integrated-storage-dir>/sample.jpg",
133+
storage_type="gcp",
134+
)
135+
```
136+
137+
Create a new task with pre-defined annotations. (Class should be configured on your project in advance)
138+
139+
```python
140+
task_id = client.create_image_task(
141+
project="YOUR_PROJECT_SLUG",
142+
file_path="<integrated-storage-dir>/sample.jpg",
143+
storage_type="gcp",
144+
annotations=[{
145+
"type": "bbox",
146+
"value": "annotation-value",
147+
"attributes": [
148+
{
149+
"key": "attribute-key",
150+
"value": "attribute-value"
151+
}
152+
],
153+
"points": [
154+
100, # top-left x
155+
100, # top-left y
156+
200, # bottom-right x
157+
200 # bottom-right y
158+
]
159+
}]
160+
)
161+
```
162+
163+
##### Limitation
164+
165+
- You can upload up to a size of 20 MB.
166+
167+
123168
#### Find Task
124169

125170
Find a single task.

fastlabel/__init__.py

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os
55
import re
66
from concurrent.futures import ThreadPoolExecutor
7-
from typing import List
7+
from typing import List, Literal
88

99
import cv2
1010
import numpy as np
@@ -830,6 +830,58 @@ def create_image_task(
830830

831831
return self.api.post_request(endpoint, payload=payload)
832832

833+
def create_integrated_image_task(
834+
self,
835+
project: str,
836+
storage_type: Literal["gcp"],
837+
file_path: str,
838+
status: str = None,
839+
external_status: str = None,
840+
annotations: list = None,
841+
tags: list = None,
842+
**kwargs,
843+
) -> str:
844+
"""
845+
Create a single integrated image task.
846+
847+
project is slug of your project (Required).
848+
storage type is the type of storage where your file resides (Required). e.g.) gcp
849+
file_path is a path to data in your setting storage bucket. Supported extensions are png, jpg, jpeg (Required).
850+
status can be 'registered', 'completed', 'skipped', 'reviewed', 'sent_back',
851+
'approved', 'declined' (Optional).
852+
external_status can be 'registered', 'completed', 'skipped', 'reviewed',
853+
'sent_back', 'approved', 'declined', 'customer_declined' (Optional).
854+
annotations is a list of annotation to be set in advance (Optional).
855+
tags is a list of tag to be set in advance (Optional).
856+
assignee is slug of assigned user (Optional).
857+
reviewer is slug of review user (Optional).
858+
approver is slug of approve user (Optional).
859+
external_assignee is slug of external assigned user (Optional).
860+
external_reviewer is slug of external review user (Optional).
861+
external_approver is slug of external approve user (Optional).
862+
"""
863+
endpoint = "tasks/integrated-image"
864+
if not utils.is_image_supported_ext(file_path):
865+
raise FastLabelInvalidException(
866+
"Supported extensions are png, jpg, jpeg.", 422
867+
)
868+
869+
payload = {"project": project, "filePath": file_path, "storageType": storage_type}
870+
if status:
871+
payload["status"] = status
872+
if external_status:
873+
payload["externalStatus"] = external_status
874+
if annotations:
875+
for annotation in annotations:
876+
annotation["content"] = file_path
877+
payload["annotations"] = annotations
878+
if tags:
879+
payload["tags"] = tags
880+
881+
self.__fill_assign_users(payload, **kwargs)
882+
883+
return self.api.post_request(endpoint, payload=payload)
884+
833885
def create_image_classification_task(
834886
self,
835887
project: str,

0 commit comments

Comments
 (0)