Skip to content

Commit

Permalink
Revert "Use img_prefix and seg_prefix for loading (open-mmlab#153)"
Browse files Browse the repository at this point in the history
This reverts commit 746c8d3.
  • Loading branch information
oggyfaker committed Oct 29, 2020
1 parent 8a174a3 commit 1629e15
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions mmseg/datasets/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,19 @@ def load_annotations(self, img_dir, img_suffix, ann_dir, seg_map_suffix,
with open(split) as f:
for line in f:
img_name = line.strip()
img_info = dict(filename=img_name + img_suffix)
img_file = osp.join(img_dir, img_name + img_suffix)
img_info = dict(filename=img_file)
if ann_dir is not None:
seg_map = img_name + seg_map_suffix
seg_map = osp.join(ann_dir, img_name + seg_map_suffix)
img_info['ann'] = dict(seg_map=seg_map)
img_infos.append(img_info)
else:
for img in mmcv.scandir(img_dir, img_suffix, recursive=True):
img_info = dict(filename=img)
img_file = osp.join(img_dir, img)
img_info = dict(filename=img_file)
if ann_dir is not None:
seg_map = img.replace(img_suffix, seg_map_suffix)
seg_map = osp.join(ann_dir,
img.replace(img_suffix, seg_map_suffix))
img_info['ann'] = dict(seg_map=seg_map)
img_infos.append(img_info)

Expand All @@ -168,8 +171,6 @@ def get_ann_info(self, idx):
def pre_pipeline(self, results):
"""Prepare results dict for pipeline."""
results['seg_fields'] = []
results['img_prefix'] = self.img_dir
results['seg_prefix'] = self.ann_dir
if self.custom_classes:
results['label_map'] = self.label_map

Expand Down Expand Up @@ -230,9 +231,8 @@ def get_gt_seg_maps(self):
"""Get ground truth segmentation maps for evaluation."""
gt_seg_maps = []
for img_info in self.img_infos:
seg_map = osp.join(self.ann_dir, img_info['ann']['seg_map'])
gt_seg_map = mmcv.imread(
seg_map, flag='unchanged', backend='pillow')
img_info['ann']['seg_map'], flag='unchanged', backend='pillow')
# modify if custom classes
if self.label_map is not None:
for old_id, new_id in self.label_map.items():
Expand Down

0 comments on commit 1629e15

Please sign in to comment.