Skip to content

Commit 371d20c

Browse files
authored
Merge pull request #84 from fastlabel/develop
Merget to main
2 parents 784657b + a8d453a commit 371d20c

File tree

5 files changed

+250
-28
lines changed

5 files changed

+250
-28
lines changed

README.md

Lines changed: 154 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Supported following project types:
6262
- Image - Keypoint
6363
- Image - Line
6464
- Image - Segmentation
65+
- Image - Pose Estimation(not support Create Task)
6566
- Image - All
6667

6768
#### Create Task
@@ -198,6 +199,76 @@ Example of a single image task object
198199
}
199200
```
200201

202+
Example when the project type is Image - Pose Estimation
203+
204+
```python
205+
{
206+
"id": "YOUR_TASK_ID",
207+
"name": "person.jpg",
208+
"width": 255, # image width
209+
"height": 255, # image height
210+
"url": "YOUR_TASK_URL",
211+
"status": "registered",
212+
"externalStatus": "registered",
213+
"tags": [],
214+
"assignee": "ASSIGNEE_NAME",
215+
"reviewer": "REVIEWER_NAME",
216+
"externalAssignee": "EXTERNAL_ASSIGNEE_NAME",
217+
"externalReviewer": "EXTERNAL_REVIEWER_NAME",
218+
"annotations":[
219+
{
220+
"type":"pose_estimation",
221+
"title":"jesture",
222+
"value":"jesture",
223+
"color":"#10c414",
224+
"attributes": [],
225+
"keypoints":[
226+
{
227+
"name":"",
228+
"key":"head",
229+
"value":[
230+
102.59, # x
231+
23.04, # y
232+
1 # 0:invisible, 1:visible
233+
],
234+
"edges":[
235+
"right_shoulder",
236+
"left_shoulder"
237+
]
238+
},
239+
{
240+
"name":"右肩",
241+
"key":"right_shoulder",
242+
"value":[
243+
186.69,
244+
114.11,
245+
1
246+
],
247+
"edges":[
248+
"head"
249+
]
250+
},
251+
{
252+
"name":"左肩",
253+
"key":"left_shoulder",
254+
"value":[
255+
37.23,
256+
109.29,
257+
1
258+
],
259+
"edges":[
260+
"head"
261+
]
262+
}
263+
]
264+
}
265+
],
266+
"createdAt": "2021-02-22T11:25:27.158Z",
267+
"updatedAt": "2021-02-22T11:25:27.158Z"
268+
}
269+
```
270+
271+
201272
### Image Classification
202273

203274
Supported following project types:
@@ -744,6 +815,55 @@ Example of an annotation object
744815
}
745816
```
746817

818+
Example when the annotation type is Pose Estimation
819+
```python
820+
{
821+
"id":"b12c81c3-ddec-4f98-b41b-cef7f77d26a4",
822+
"type":"pose_estimation",
823+
"title":"jesture",
824+
"value":"jesture",
825+
"color":"#10c414",
826+
"order":1,
827+
"attributes": [],
828+
"keypoints":[
829+
{
830+
"id":"b03ea998-a2f1-4733-b7e9-78cdf73bd38a",
831+
"name":"",
832+
"key":"head",
833+
"color":"#0033CC",
834+
"edges":[
835+
"195f5852-c516-498b-b392-24513ce3ea67",
836+
"06b5c968-1786-4d75-a719-951e915e5557"
837+
],
838+
"value": []
839+
},
840+
{
841+
"id":"195f5852-c516-498b-b392-24513ce3ea67",
842+
"name":"右肩",
843+
"key":"right_shoulder",
844+
"color":"#0033CC",
845+
"edges":[
846+
"b03ea998-a2f1-4733-b7e9-78cdf73bd38a"
847+
],
848+
"value": []
849+
},
850+
{
851+
"id":"06b5c968-1786-4d75-a719-951e915e5557",
852+
"name":"左肩",
853+
"key":"left_shoulder",
854+
"color":"#0033CC",
855+
"edges":[
856+
"b03ea998-a2f1-4733-b7e9-78cdf73bd38a"
857+
],
858+
"value": []
859+
}
860+
],
861+
"createdAt":"2021-11-21T09:59:46.714Z",
862+
"updatedAt":"2021-11-21T09:59:46.714Z"
863+
}
864+
```
865+
866+
747867
### Update Annotation
748868

749869
Update an annotation.
@@ -869,10 +989,14 @@ client.delete_project(project_id="YOUR_PROJECT_ID")
869989

870990
## Converter
871991

872-
Supporting bbox or polygon annotation type.
873-
874992
### COCO
875993

994+
Support the following annotation types.
995+
996+
- bbox
997+
- polygon
998+
- pose estimation
999+
8761000
Get tasks and export as a [COCO format](https://cocodataset.org/#format-data) file.
8771001

8781002
```python
@@ -886,8 +1010,22 @@ Export with specifying output directory.
8861010
client.export_coco(tasks=tasks, output_dir="YOUR_DIRECTROY")
8871011
```
8881012

1013+
If you would like to export pose estimation type annotations, please pass annotations.
1014+
1015+
```python
1016+
project_slug = "YOUR_PROJECT_SLUG"
1017+
tasks = client.get_image_tasks(project=project_slug)
1018+
annotations = client.get_annotations(project=project_slug)
1019+
client.export_coco(tasks=tasks, annotations=annotations, output_dir="YOUR_DIRECTROY")
1020+
```
1021+
8891022
### YOLO
8901023

1024+
Support the following annotation types.
1025+
1026+
- bbox
1027+
- polygon
1028+
8911029
Get tasks and export as YOLO format files.
8921030

8931031
```python
@@ -908,6 +1046,11 @@ client.export_yolo(tasks=tasks, classes=classes, output_dir="YOUR_DIRECTROY")
9081046

9091047
### Pascal VOC
9101048

1049+
Support the following annotation types.
1050+
1051+
- bbox
1052+
- polygon
1053+
9111054
Get tasks and export as Pascal VOC format files.
9121055

9131056
```python
@@ -917,6 +1060,14 @@ client.export_pascalvoc(tasks)
9171060

9181061
### labelme
9191062

1063+
Support the following annotation types.
1064+
1065+
- bbox
1066+
- polygon
1067+
- points
1068+
- line
1069+
1070+
9201071
Get tasks and export as labelme format files.
9211072

9221073
```python
@@ -1185,7 +1336,7 @@ for image_file_path in glob.iglob(os.path.join(input_dataset_path, "**/**.jpg"),
11851336

11861337
### labelme
11871338

1188-
support the following annotation types.
1339+
Support the following annotation types.
11891340

11901341
- bbox
11911342
- polygon

fastlabel/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,14 +1021,16 @@ def __get_yolo_format_annotations(self, dataset_folder_path: str) -> dict:
10211021

10221022
# Task Convert
10231023

1024-
def export_coco(self, tasks: list, output_dir: str = os.path.join("output", "coco")) -> None:
1024+
def export_coco(self, tasks: list, annotations: list = [], output_dir: str = os.path.join("output", "coco")) -> None:
10251025
"""
10261026
Convert tasks to COCO format and export as a file.
1027+
If you pass annotations, you can export Pose Estimation type annotations.
10271028
10281029
tasks is a list of tasks. (Required)
1030+
annotations is a list of annotations. (Optional)
10291031
output_dir is output directory(default: output/coco). (Optional)
10301032
"""
1031-
coco = converters.to_coco(tasks)
1033+
coco = converters.to_coco(tasks, annotations)
10321034
os.makedirs(output_dir, exist_ok=True)
10331035
file_path = os.path.join(output_dir, "annotations.json")
10341036
with open(file_path, 'w') as f:

fastlabel/const.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ class AnnotationType(Enum):
99
keypoint = "keypoint"
1010
line = "line"
1111
segmentation = "segmentation"
12-
classification = "classification"
12+
classification = "classification"
13+
pose_estimation = "pose_estimation"

0 commit comments

Comments
 (0)