Skip to content

Commit 6de78b3

Browse files
authored
Merge pull request #94 from fastlabel/develop
Merge to main
2 parents d332477 + 1a67268 commit 6de78b3

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,10 +1043,10 @@ tasks = client.get_image_tasks(project="YOUR_PROJECT_SLUG")
10431043
client.export_coco(tasks)
10441044
```
10451045

1046-
Export with specifying output directory.
1046+
Export with specifying output directory and file name.
10471047

10481048
```python
1049-
client.export_coco(tasks=tasks, output_dir="YOUR_DIRECTROY")
1049+
client.export_coco(tasks=tasks, output_dir="YOUR_DIRECTROY", output_file_name="YOUR_FILE_NAME")
10501050
```
10511051

10521052
If you would like to export pose estimation type annotations, please pass annotations.
@@ -1055,7 +1055,7 @@ If you would like to export pose estimation type annotations, please pass annota
10551055
project_slug = "YOUR_PROJECT_SLUG"
10561056
tasks = client.get_image_tasks(project=project_slug)
10571057
annotations = client.get_annotations(project=project_slug)
1058-
client.export_coco(tasks=tasks, annotations=annotations, output_dir="YOUR_DIRECTROY")
1058+
client.export_coco(tasks=tasks, annotations=annotations, output_dir="YOUR_DIRECTROY", output_file_name="YOUR_FILE_NAME")
10591059
```
10601060

10611061
### YOLO

fastlabel/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,18 +1082,22 @@ def __get_yolo_format_annotations(self, dataset_folder_path: str) -> dict:
10821082

10831083
# Task Convert
10841084

1085-
def export_coco(self, tasks: list, annotations: list = [], output_dir: str = os.path.join("output", "coco")) -> None:
1085+
def export_coco(self, tasks: list, annotations: list = [], output_dir: str = os.path.join("output", "coco"), output_file_name: str = "annotations.json") -> None:
10861086
"""
10871087
Convert tasks to COCO format and export as a file.
10881088
If you pass annotations, you can export Pose Estimation type annotations.
10891089
10901090
tasks is a list of tasks. (Required)
10911091
annotations is a list of annotations. (Optional)
10921092
output_dir is output directory(default: output/coco). (Optional)
1093+
output_file_name is output file name(default: annotations.json). (Optional)
10931094
"""
1095+
if not utils.is_json_ext(output_file_name):
1096+
raise FastLabelInvalidException(
1097+
"Output file name must have a json extension", 422)
10941098
coco = converters.to_coco(tasks, annotations)
10951099
os.makedirs(output_dir, exist_ok=True)
1096-
file_path = os.path.join(output_dir, "annotations.json")
1100+
file_path = os.path.join(output_dir, output_file_name)
10971101
with open(file_path, 'w') as f:
10981102
json.dump(coco, f, indent=4, ensure_ascii=False)
10991103

fastlabel/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ def is_video_supported_ext(file_path: str) -> bool:
1919
return file_path.lower().endswith('.mp4')
2020

2121

22+
def is_json_ext(file_name: str) -> bool:
23+
return file_name.lower().endswith('.json')
24+
25+
2226
def get_basename(file_path: str) -> str:
2327
"""
2428
e.g.) file.jpg -> file

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setuptools.setup(
1010
name="fastlabel",
11-
version="0.11.11",
11+
version="0.11.12",
1212
author="eisuke-ueta",
1313
author_email="[email protected]",
1414
description="The official Python SDK for FastLabel API, the Data Platform for AI",

0 commit comments

Comments
 (0)