Skip to content

Update labelstudio2coco.py , 1. image_name changed 2. can't get category_id #2930

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions tools/dataset_converters/labelstudio2coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def add_image(images, width, height, image_id, image_path):

for item_idx, item in enumerate(ann_list):
# each image is an item
image_name = item['file_upload']
image_name = item['data']['img']
image_id = len(images)
width, height = None, None

Expand Down Expand Up @@ -143,7 +143,6 @@ def add_image(images, width, height, image_id, image_path):
images = add_image(images, width, height, image_id,
image_name)

category_id = self.category_name_to_id[category_name]

annotation_id = len(annotations)

Expand Down Expand Up @@ -201,6 +200,7 @@ def add_image(images, width, height, image_id, image_path):

# create new annotation in coco
# when the keypoint is the first point of an instance
category_id = self.category_name_to_id[category_name]
if i == 0 or item['annotations'][0]['result'][
i - 1]['type'] != 'keypointlabels':
annotations.append({
Expand Down