diff --git a/src/functions.py b/src/functions.py index 2bc6b28..88a6cd0 100644 --- a/src/functions.py +++ b/src/functions.py @@ -7,6 +7,7 @@ from supervisely.geometry import bitmap from supervisely.io.fs import mkdir +total_img_count = 0 def get_categories_map_from_meta(meta): obj_classes = meta.obj_classes @@ -87,6 +88,7 @@ def create_coco_annotation( include_captions, rectangle_mark, ): + global total_img_count for img_idx, (image_info, ann) in enumerate(zip(image_infos, anns)): image_coco_ann = dict( license="None", @@ -95,7 +97,7 @@ def create_coco_annotation( height=image_info.height, width=image_info.width, date_captured=image_info.created_at, - id=img_idx, # incremental id + id=img_idx + total_img_count, # incremental id sly_id=image_info.id # supervisely image id ) coco_ann["images"].append(image_coco_ann) @@ -148,6 +150,7 @@ def create_coco_annotation( ) ) progress.iter_done_report() + total_img_count += len(image_infos) return coco_ann, label_id, coco_captions, caption_id