fix bug about label_map (#1445)

* fix bug about label_map

* Update mmseg/datasets/pipelines/loading.py

Co-authored-by: MengzhangLI <mcmong@pku.edu.cn>

* lint

Co-authored-by: MengzhangLI <mcmong@pku.edu.cn>
Co-authored-by: MeowZheng <meowzheng@outlook.com>
pull/1472/head
Yzichen 2022-04-09 21:11:47 +08:00 committed by GitHub
parent 4bd32f4c3d
commit 28488851fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -135,8 +135,12 @@ class LoadAnnotations(object):
backend=self.imdecode_backend).squeeze().astype(np.uint8)
# modify if custom classes
if results.get('label_map', None) is not None:
# Add deep copy to solve bug of repeatedly
# replace `gt_semantic_seg`, which is reported in
# https://github.com/open-mmlab/mmsegmentation/pull/1445/
gt_semantic_seg_copy = gt_semantic_seg.copy()
for old_id, new_id in results['label_map'].items():
gt_semantic_seg[gt_semantic_seg == old_id] = new_id
gt_semantic_seg[gt_semantic_seg_copy == old_id] = new_id
# reduce zero_label
if self.reduce_zero_label:
# avoid using underflow conversion