File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -53,12 +53,15 @@ def calculate_confusion_matrix(dataset, results):
5353 n = len (dataset .CLASSES )
5454 confusion_matrix = np .zeros (shape = [n , n ])
5555 assert len (dataset ) == len (results )
56+ ignore_index = dataset .ignore_index
5657 prog_bar = mmcv .ProgressBar (len (results ))
5758 for idx , per_img_res in enumerate (results ):
5859 res_segm = per_img_res
59- gt_segm = dataset .get_gt_seg_map_by_idx (idx )
60+ gt_segm = dataset .get_gt_seg_map_by_idx (idx ).astype (int )
61+ gt_segm , res_segm = gt_segm .flatten (), res_segm .flatten ()
62+ to_ignore = gt_segm == ignore_index
63+ gt_segm , res_segm = gt_segm [~ to_ignore ], res_segm [~ to_ignore ]
6064 inds = n * gt_segm + res_segm
61- inds = inds .flatten ()
6265 mat = np .bincount (inds , minlength = n ** 2 ).reshape (n , n )
6366 confusion_matrix += mat
6467 prog_bar .update ()
You can’t perform that action at this time.
0 commit comments