From 4764f1611f84b611028c584f47bad016b342837a Mon Sep 17 00:00:00 2001 From: kmkkiii Date: Mon, 17 Mar 2025 16:01:34 +0900 Subject: [PATCH 1/6] =?UTF-8?q?COCO=E5=87=BA=E5=8A=9B=E6=99=82=E3=81=AB?= =?UTF-8?q?=E7=9F=A9=E5=BD=A2=E3=82=A2=E3=83=8E=E3=83=86=E3=83=BC=E3=82=B7?= =?UTF-8?q?=E3=83=A7=E3=83=B3=E3=81=AE=E3=82=AD=E3=83=BC=E3=83=9D=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=83=88=E6=83=85=E5=A0=B1=E3=82=82=E5=87=BA=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastlabel/converters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastlabel/converters.py b/fastlabel/converters.py index e411b32..e64fac4 100644 --- a/fastlabel/converters.py +++ b/fastlabel/converters.py @@ -180,7 +180,7 @@ 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"]) From 465a0b6ad7a594f6ef8213cb709c4173b8236f12 Mon Sep 17 00:00:00 2001 From: kmkkiii Date: Mon, 17 Mar 2025 16:03:27 +0900 Subject: [PATCH 2/6] add export_coco example --- examples/export_coco.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 examples/export_coco.py diff --git a/examples/export_coco.py b/examples/export_coco.py new file mode 100644 index 0000000..3749209 --- /dev/null +++ b/examples/export_coco.py @@ -0,0 +1,9 @@ +import fastlabel + +client = fastlabel.Client() + +project_slug = "issue-9274" +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/") From 9a0779f6a26a32bf0fcac4f6395c346044a8b853 Mon Sep 17 00:00:00 2001 From: kmkkiii Date: Mon, 17 Mar 2025 16:03:43 +0900 Subject: [PATCH 3/6] fix README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" From 15d53e459d9caa02d41b59739f8f866e2ab37c72 Mon Sep 17 00:00:00 2001 From: kmkkiii Date: Mon, 17 Mar 2025 16:11:41 +0900 Subject: [PATCH 4/6] fix docstring --- fastlabel/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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). From deaf4e5c76df866d1e0b889a1a82455d378cad9e Mon Sep 17 00:00:00 2001 From: kmkkiii Date: Mon, 17 Mar 2025 16:17:00 +0900 Subject: [PATCH 5/6] fix black --- examples/export_coco.py | 7 ++++++- fastlabel/converters.py | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/export_coco.py b/examples/export_coco.py index 3749209..437630d 100644 --- a/examples/export_coco.py +++ b/examples/export_coco.py @@ -6,4 +6,9 @@ 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/") +client.export_coco( + project=project_slug, + tasks=tasks, + annotations=annotations, + output_dir="./export_coco/", +) diff --git a/fastlabel/converters.py b/fastlabel/converters.py index e64fac4..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"] in [AnnotationType.pose_estimation.value, AnnotationType.bbox.value]: + if annotation["type"] in [ + AnnotationType.pose_estimation.value, + AnnotationType.bbox.value, + ]: keypoints = annotation["keypoints"] for keypoint in keypoints: coco_keypoints.append(keypoint["key"]) From e1b1a763071d8fe00a1a17bab57d6cba308e84b0 Mon Sep 17 00:00:00 2001 From: kmkkiii Date: Mon, 17 Mar 2025 16:31:05 +0900 Subject: [PATCH 6/6] fix project_slug value --- examples/export_coco.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/export_coco.py b/examples/export_coco.py index 437630d..31caf2e 100644 --- a/examples/export_coco.py +++ b/examples/export_coco.py @@ -2,7 +2,7 @@ client = fastlabel.Client() -project_slug = "issue-9274" +project_slug = "YOUR_PROJECT_SLUG" tasks = client.get_image_tasks(project=project_slug) annotations = client.get_annotations(project=project_slug)