From 191bf2761cb4b16148c80a600cc8f642d9023d62 Mon Sep 17 00:00:00 2001 From: Andrey Zhavoronkov <41117609+azhavoro@users.noreply.github.com> Date: Fri, 30 Aug 2019 12:12:08 +0300 Subject: [PATCH] fixed annotation ids, start category id from 1 (#680) --- cvat/apps/annotation/coco.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cvat/apps/annotation/coco.py b/cvat/apps/annotation/coco.py index 50f83d39..616639f9 100644 --- a/cvat/apps/annotation/coco.py +++ b/cvat/apps/annotation/coco.py @@ -195,7 +195,7 @@ def dump(file_object, annotations): # Sort labels by its names to make the same order of ids for different annotations if sort: names.sort() - cat_id = 0 + cat_id = 1 for name in names: category_map[name] = cat_id categories.append(OrderedDict([ @@ -264,6 +264,7 @@ def dump(file_object, annotations): insert_info_data(annotations, result_annotation) category_map = insert_categories_data(annotations, result_annotation) + segm_id = 0 for img in annotations.group_by_frame(): polygons = [] @@ -310,8 +311,9 @@ def dump(file_object, annotations): polygons = ungrouped_poligons + [poly for group in grouped_poligons.values() for poly in group.values()] # Create new annotation for this image - for segm_id, poly in enumerate(polygons): + for poly in polygons: insert_annotation_data(img, category_map, segm_id, poly, result_annotation) + segm_id += 1 file_object.write(json.dumps(result_annotation, indent=2).encode()) file_object.flush()