@@ -190,42 +190,46 @@ def _retrieve_per_category_metrics(self, coco_eval, prefix=''):
190
190
191
191
if hasattr (coco_eval , 'category_stats' ):
192
192
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 )
196
+
193
197
metrics_dict [prefix + 'Precision mAP ByCategory/{}' .format (
194
- category_id )] = coco_eval . category_stats [ 0 ][ category_index ]. astype (
195
- np .float32 )
198
+ category_display_name
199
+ )] = coco_eval . category_stats [ 0 ][ category_index ]. astype ( np .float32 )
196
200
metrics_dict [prefix + 'Precision mAP ByCategory@50IoU/{}' .format (
197
- category_id )] = coco_eval . category_stats [ 1 ][ category_index ]. astype (
198
- np .float32 )
201
+ category_display_name
202
+ )] = coco_eval . category_stats [ 1 ][ category_index ]. astype ( np .float32 )
199
203
metrics_dict [prefix + 'Precision mAP ByCategory@75IoU/{}' .format (
200
- category_id )] = coco_eval . category_stats [ 2 ][ category_index ]. astype (
201
- np .float32 )
202
- metrics_dict [prefix + 'Precision mAP ByCategory (small) /{}' .format (
203
- category_id )] = coco_eval . category_stats [ 3 ][ category_index ]. astype (
204
- np .float32 )
205
- metrics_dict [prefix + 'Precision mAP ByCategory (medium) /{}' .format (
206
- category_id )] = coco_eval . category_stats [ 4 ][ category_index ]. astype (
207
- np .float32 )
204
+ category_display_name
205
+ )] = coco_eval . category_stats [ 2 ][ category_index ]. astype ( np .float32 )
206
+ metrics_dict [prefix + 'Precision mAP ByCategory (small) /{}' .format (
207
+ category_display_name
208
+ )] = coco_eval . category_stats [ 3 ][ category_index ]. astype ( np .float32 )
209
+ metrics_dict [prefix + 'Precision mAP ByCategory (medium) /{}' .format (
210
+ category_display_name
211
+ )] = coco_eval . category_stats [ 4 ][ category_index ]. astype ( np .float32 )
208
212
metrics_dict [prefix + 'Precision mAP ByCategory (large) /{}' .format (
209
- category_id )] = coco_eval . category_stats [ 5 ][ category_index ]. astype (
210
- np .float32 )
213
+ category_display_name
214
+ )] = coco_eval . category_stats [ 5 ][ category_index ]. astype ( np .float32 )
211
215
metrics_dict [prefix + 'Recall AR@1 ByCategory/{}' .format (
212
- category_id )] = coco_eval . category_stats [ 6 ][ category_index ]. astype (
213
- np .float32 )
216
+ category_display_name
217
+ )] = coco_eval . category_stats [ 6 ][ category_index ]. astype ( np .float32 )
214
218
metrics_dict [prefix + 'Recall AR@10 ByCategory/{}' .format (
215
- category_id )] = coco_eval . category_stats [ 7 ][ category_index ]. astype (
216
- np .float32 )
219
+ category_display_name
220
+ )] = coco_eval . category_stats [ 7 ][ category_index ]. astype ( np .float32 )
217
221
metrics_dict [prefix + 'Recall AR@100 ByCategory/{}' .format (
218
- category_id )] = coco_eval . category_stats [ 8 ][ category_index ]. astype (
219
- np .float32 )
222
+ category_display_name
223
+ )] = coco_eval . category_stats [ 8 ][ category_index ]. astype ( np .float32 )
220
224
metrics_dict [prefix + 'Recall AR (small) ByCategory/{}' .format (
221
- category_id )] = coco_eval . category_stats [ 9 ][ category_index ]. astype (
222
- np .float32 )
225
+ category_display_name
226
+ )] = coco_eval . category_stats [ 9 ][ category_index ]. astype ( np .float32 )
223
227
metrics_dict [prefix + 'Recall AR (medium) ByCategory/{}' .format (
224
- category_id )] = coco_eval . category_stats [ 10 ][ category_index ]. astype (
225
- np .float32 )
228
+ category_display_name
229
+ )] = coco_eval . category_stats [ 10 ][ category_index ]. astype ( np .float32 )
226
230
metrics_dict [prefix + 'Recall AR (large) ByCategory/{}' .format (
227
- category_id )] = coco_eval . category_stats [ 11 ][ category_index ]. astype (
228
- np .float32 )
231
+ category_display_name
232
+ )] = coco_eval . category_stats [ 11 ][ category_index ]. astype ( np .float32 )
229
233
230
234
return metrics_dict
231
235
0 commit comments