Skip to content

Commit 2b436a1

Browse files
Internal change
PiperOrigin-RevId: 338364871
1 parent 95f2b04 commit 2b436a1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

official/vision/beta/evaluation/coco_evaluator.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,12 @@ def _retrieve_per_category_metrics(self, coco_eval, prefix=''):
190190

191191
if hasattr(coco_eval, 'category_stats'):
192192
for category_index, category_id in enumerate(coco_eval.params.catIds):
193-
coco_category = self._coco_gt.cats[category_id]
194-
# if 'name' is available use it, otherwise use `id`
195-
category_display_name = coco_category.get('name', category_id)
193+
if self._annotation_file:
194+
coco_category = self._coco_gt.cats[category_id]
195+
# if 'name' is available use it, otherwise use `id`
196+
category_display_name = coco_category.get('name', category_id)
197+
else:
198+
category_display_name = category_id
196199

197200
metrics_dict[prefix + 'Precision mAP ByCategory/{}'.format(
198201
category_display_name

0 commit comments

Comments
 (0)