Skip to content

Commit

Permalink
Fix Incremental ID (#28)
Browse files Browse the repository at this point in the history
* fix incremental id

* fix unbound variable

---------

Co-authored-by: vorozhkog <[email protected]>
  • Loading branch information
vorozhkog and vorozhkog authored Nov 4, 2024
1 parent e71b064 commit ff7ad99
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -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)
Expand Down Expand Up @@ -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


Expand Down

0 comments on commit ff7ad99

Please sign in to comment.