Skip to content

Commit

Permalink
Fixed Bug as explained in Issue #1969 (#1992)
Browse files Browse the repository at this point in the history
For explanations, have a look at

#1969
  • Loading branch information
TimoK93 committed Aug 29, 2022
1 parent 7a0f45e commit 319ab5f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tools/confusion_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,15 @@ def calculate_confusion_matrix(dataset, results):
n = len(dataset.CLASSES)
confusion_matrix = np.zeros(shape=[n, n])
assert len(dataset) == len(results)
ignore_index = dataset.ignore_index
prog_bar = mmcv.ProgressBar(len(results))
for idx, per_img_res in enumerate(results):
res_segm = per_img_res
gt_segm = dataset.get_gt_seg_map_by_idx(idx)
gt_segm = dataset.get_gt_seg_map_by_idx(idx).astype(int)
gt_segm, res_segm = gt_segm.flatten(), res_segm.flatten()
to_ignore = gt_segm == ignore_index
gt_segm, res_segm = gt_segm[~to_ignore], res_segm[~to_ignore]
inds = n * gt_segm + res_segm
inds = inds.flatten()
mat = np.bincount(inds, minlength=n**2).reshape(n, n)
confusion_matrix += mat
prog_bar.update()
Expand Down

0 comments on commit 319ab5f

Please sign in to comment.