Skip to content

Commit bf93e92

Browse files
authored
Merge pull request #243 from fastlabel/feature/9274_add-bbox-keypoints-to-export-coco
export_cocoでキーポイント付きの矩形のkeypointが出力されるようにする
2 parents ad06bf6 + e1b1a76 commit bf93e92

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2956,7 +2956,7 @@ Export with specifying output directory and file name.
29562956
client.export_coco(project="YOUR_PROJECT_SLUG", tasks=tasks, output_dir="YOUR_DIRECTROY", output_file_name="YOUR_FILE_NAME")
29572957
```
29582958

2959-
If you would like to export pose estimation type annotations, please pass annotations.
2959+
If you would like to export pose estimation type annotations or bbox type annotations with keypoints, please pass annotations.
29602960

29612961
```python
29622962
project_slug = "YOUR_PROJECT_SLUG"

examples/export_coco.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import fastlabel
2+
3+
client = fastlabel.Client()
4+
5+
project_slug = "YOUR_PROJECT_SLUG"
6+
tasks = client.get_image_tasks(project=project_slug)
7+
annotations = client.get_annotations(project=project_slug)
8+
9+
client.export_coco(
10+
project=project_slug,
11+
tasks=tasks,
12+
annotations=annotations,
13+
output_dir="./export_coco/",
14+
)

fastlabel/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3136,7 +3136,7 @@ def export_coco(
31363136
) -> None:
31373137
"""
31383138
Convert tasks to COCO format and export as a file.
3139-
If you pass annotations, you can export Pose Estimation type annotations.
3139+
If you pass annotations, you can export Pose Estimation type annotations or Bbox type annotations with keypoints.
31403140
31413141
project is slug of your project (Required).
31423142
tasks is a list of tasks (Required).

fastlabel/converters.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,10 @@ def __get_coco_categories(tasks: list, annotations: list) -> list:
180180
coco_skeleton = []
181181
coco_keypoints = []
182182
coco_keypoint_colors = []
183-
if annotation["type"] == AnnotationType.pose_estimation.value:
183+
if annotation["type"] in [
184+
AnnotationType.pose_estimation.value,
185+
AnnotationType.bbox.value,
186+
]:
184187
keypoints = annotation["keypoints"]
185188
for keypoint in keypoints:
186189
coco_keypoints.append(keypoint["key"])

0 commit comments

Comments
 (0)