@@ -255,8 +255,9 @@ def parse_ann_info(self, info: dict) -> Optional[dict]:
255
255
ann_info ['instances' ] = info ['instances' ]
256
256
257
257
for label in ann_info ['gt_labels_3d' ]:
258
- cat_name = self .metainfo ['classes' ][label ]
259
- self .num_ins_per_cat [cat_name ] += 1
258
+ if label != - 1 :
259
+ cat_name = self .metainfo ['classes' ][label ]
260
+ self .num_ins_per_cat [cat_name ] += 1
260
261
261
262
return ann_info
262
263
@@ -336,12 +337,16 @@ def _show_ins_var(self, old_labels: np.ndarray, new_labels: torch.Tensor):
336
337
"""
337
338
ori_num_per_cat = dict ()
338
339
for label in old_labels :
339
- cat_name = self .metainfo ['classes' ][label ]
340
- ori_num_per_cat [cat_name ] = ori_num_per_cat .get (cat_name , 0 ) + 1
340
+ if label != - 1 :
341
+ cat_name = self .metainfo ['classes' ][label ]
342
+ ori_num_per_cat [cat_name ] = ori_num_per_cat .get (cat_name ,
343
+ 0 ) + 1
341
344
new_num_per_cat = dict ()
342
345
for label in new_labels :
343
- cat_name = self .metainfo ['classes' ][label ]
344
- new_num_per_cat [cat_name ] = new_num_per_cat .get (cat_name , 0 ) + 1
346
+ if label != - 1 :
347
+ cat_name = self .metainfo ['classes' ][label ]
348
+ new_num_per_cat [cat_name ] = new_num_per_cat .get (cat_name ,
349
+ 0 ) + 1
345
350
content_show = [['category' , 'new number' , 'ori number' ]]
346
351
for cat_name , num in ori_num_per_cat .items ():
347
352
new_num = new_num_per_cat .get (cat_name , 0 )
@@ -387,9 +392,16 @@ def prepare_data(self, index: int) -> Optional[dict]:
387
392
return None
388
393
389
394
if self .show_ins_var :
390
- self ._show_ins_var (
391
- ori_input_dict ['ann_info' ]['gt_labels_3d' ],
392
- example ['data_samples' ].gt_instances_3d .labels_3d )
395
+ if 'ann_info' in ori_input_dict :
396
+ self ._show_ins_var (
397
+ ori_input_dict ['ann_info' ]['gt_labels_3d' ],
398
+ example ['data_samples' ].gt_instances_3d .labels_3d )
399
+ else :
400
+ print_log (
401
+ "'ann_info' is not in the input dict. It's probably that "
402
+ 'the data is not in training mode' ,
403
+ 'current' ,
404
+ level = 30 )
393
405
394
406
return example
395
407
0 commit comments