Skip to content

[Fix] Fix bugs in the output annotation file when --class-id-txt is set. #430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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