diff --git a/tools/dataset_converters/labelstudio2coco.py b/tools/dataset_converters/labelstudio2coco.py index 12f4c61851..f5d519a6aa 100755 --- a/tools/dataset_converters/labelstudio2coco.py +++ b/tools/dataset_converters/labelstudio2coco.py @@ -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 @@ -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) @@ -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({