@@ -272,7 +272,7 @@ def generator() -> DatasetIterator:
272272 with open (ann_path ) as f :
273273 annotation_data = f .readlines ()
274274
275- for ann_line in annotation_data :
275+ for instance_id , ann_line in enumerate ( annotation_data ) :
276276 if not ann_line .strip ():
277277 continue
278278
@@ -299,6 +299,7 @@ def generator() -> DatasetIterator:
299299 "file" : str (img_path ),
300300 "annotation" : {
301301 "class" : class_name ,
302+ "instance_id" : instance_id ,
302303 "boundingbox" : {
303304 "x" : float (x_center ) - float (width ) / 2 ,
304305 "y" : float (y_center ) - float (height ) / 2 ,
@@ -323,6 +324,7 @@ def generator() -> DatasetIterator:
323324 "file" : str (img_path ),
324325 "annotation" : {
325326 "class" : class_name ,
327+ "instance_id" : instance_id ,
326328 "boundingbox" : boundingbox ,
327329 "instance_segmentation" : {
328330 "height" : height ,
@@ -357,6 +359,7 @@ def generator() -> DatasetIterator:
357359 "file" : str (img_path ),
358360 "annotation" : {
359361 "class" : class_name ,
362+ "instance_id" : instance_id ,
360363 "boundingbox" : {
361364 "x" : float (x_center ) - float (width ) / 2 ,
362365 "y" : float (y_center ) - float (height ) / 2 ,
@@ -369,6 +372,8 @@ def generator() -> DatasetIterator:
369372 },
370373 }
371374
375+ instance_id += 1
376+
372377 added_images = self ._get_added_images (generator ())
373378
374379 return generator (), {}, added_images
0 commit comments