Avoid converting label ids twice by label map during evaluation (#1417)

* Avoid converting label ids twice by label map during evaluation

* Update mmseg/datasets/custom.py

Co-authored-by: Miao Zheng <76149310+MeowZheng@users.noreply.github.com>

* lint

Co-authored-by: Miao Zheng <76149310+MeowZheng@users.noreply.github.com>
Co-authored-by: MeowZheng <meowzheng@outlook.com>
pull/1461/merge
panfeng-hover 2022-04-12 03:26:25 -07:00 committed by GitHub
parent 4841933454
commit 91b1bcb9d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 4 deletions

View File

@ -298,9 +298,18 @@ class CustomDataset(Dataset):
for pred, index in zip(preds, indices):
seg_map = self.get_gt_seg_map_by_idx(index)
pre_eval_results.append(
intersect_and_union(pred, seg_map, len(self.CLASSES),
self.ignore_index, self.label_map,
self.reduce_zero_label))
intersect_and_union(
pred,
seg_map,
len(self.CLASSES),
self.ignore_index,
# as the labels has been converted when dataset initialized
# in `get_palette_for_custom_classes ` this `label_map`
# should be `dict()`, see
# https://github.com/open-mmlab/mmsegmentation/issues/1415
# for more ditails
label_map=dict(),
reduce_zero_label=self.reduce_zero_label))
return pre_eval_results
@ -417,7 +426,7 @@ class CustomDataset(Dataset):
num_classes,
self.ignore_index,
metric,
label_map=self.label_map,
label_map=dict(),
reduce_zero_label=self.reduce_zero_label)
# test a list of pre_eval_results
else: