Skip to content

Commit 319ab5f

Browse files
authored
Fixed Bug as explained in Issue open-mmlab#1969 (open-mmlab#1992)
For explanations, have a look at open-mmlab#1969
1 parent 7a0f45e commit 319ab5f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tools/confusion_matrix.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff 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()

0 commit comments

Comments
 (0)