Skip to content

Commit

Permalink
[Fix] Fix bugs in the output annotation file when --class-id-txt is…
Browse files Browse the repository at this point in the history
… set. (#430)

* [Fix] Fix bugs in the output annotation file when  is set.

* Update labelme2coco.py

* Update labelme2coco.py

* Improve code

Co-authored-by: HinGwenWoong <[email protected]>
  • Loading branch information
VoyagerXvoyagerx and PeterH0323 authored Jan 6, 2023
1 parent d8cbf21 commit 2290713
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tools/dataset_converters/labelme2coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ def parse_labelme_to_coco(
category_to_id = all_classes_id
categories_labels = list(all_classes_id.keys())

# add class_ids and class_names to the categories list in coco_json
for class_name, class_id in category_to_id.items():
coco_json['categories'].append({
'id': class_id,
'name': class_name
})

# filter incorrect image file
img_file_list = [
img_file for img_file in Path(image_dir).iterdir()
Expand Down Expand Up @@ -283,7 +290,7 @@ def convert_labelme_to_coco(image_dir: str,
' words, like "1 Big house" -> "1 '
'Big-house".')
v, k = class_info
all_classes_id.update({k: v})
all_classes_id.update({k: int(v)})
else:
all_classes_id = None

Expand Down

0 comments on commit 2290713

Please sign in to comment.