diff --git a/README.md b/README.md index b3027a5..2c87942 100644 --- a/README.md +++ b/README.md @@ -2956,7 +2956,7 @@ Export with specifying output directory and file name. client.export_coco(project="YOUR_PROJECT_SLUG", tasks=tasks, output_dir="YOUR_DIRECTROY", output_file_name="YOUR_FILE_NAME") ``` -If you would like to export pose estimation type annotations, please pass annotations. +If you would like to export pose estimation type annotations or bbox type annotations with keypoints, please pass annotations. ```python project_slug = "YOUR_PROJECT_SLUG" diff --git a/examples/export_coco.py b/examples/export_coco.py new file mode 100644 index 0000000..31caf2e --- /dev/null +++ b/examples/export_coco.py @@ -0,0 +1,14 @@ +import fastlabel + +client = fastlabel.Client() + +project_slug = "YOUR_PROJECT_SLUG" +tasks = client.get_image_tasks(project=project_slug) +annotations = client.get_annotations(project=project_slug) + +client.export_coco( + project=project_slug, + tasks=tasks, + annotations=annotations, + output_dir="./export_coco/", +) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index f3c112f..0372f09 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -3136,7 +3136,7 @@ def export_coco( ) -> None: """ Convert tasks to COCO format and export as a file. - If you pass annotations, you can export Pose Estimation type annotations. + If you pass annotations, you can export Pose Estimation type annotations or Bbox type annotations with keypoints. project is slug of your project (Required). tasks is a list of tasks (Required). diff --git a/fastlabel/converters.py b/fastlabel/converters.py index e411b32..077e986 100644 --- a/fastlabel/converters.py +++ b/fastlabel/converters.py @@ -180,7 +180,10 @@ def __get_coco_categories(tasks: list, annotations: list) -> list: coco_skeleton = [] coco_keypoints = [] coco_keypoint_colors = [] - if annotation["type"] == AnnotationType.pose_estimation.value: + if annotation["type"] in [ + AnnotationType.pose_estimation.value, + AnnotationType.bbox.value, + ]: keypoints = annotation["keypoints"] for keypoint in keypoints: coco_keypoints.append(keypoint["key"])