@@ -131,19 +131,16 @@ def load_annotations(self, img_dir, img_suffix, ann_dir, seg_map_suffix,
131131 with open (split ) as f :
132132 for line in f :
133133 img_name = line .strip ()
134- img_file = osp .join (img_dir , img_name + img_suffix )
135- img_info = dict (filename = img_file )
134+ img_info = dict (filename = img_name + img_suffix )
136135 if ann_dir is not None :
137- seg_map = osp . join ( ann_dir , img_name + seg_map_suffix )
136+ seg_map = img_name + seg_map_suffix
138137 img_info ['ann' ] = dict (seg_map = seg_map )
139138 img_infos .append (img_info )
140139 else :
141140 for img in mmcv .scandir (img_dir , img_suffix , recursive = True ):
142- img_file = osp .join (img_dir , img )
143- img_info = dict (filename = img_file )
141+ img_info = dict (filename = img )
144142 if ann_dir is not None :
145- seg_map = osp .join (ann_dir ,
146- img .replace (img_suffix , seg_map_suffix ))
143+ seg_map = img .replace (img_suffix , seg_map_suffix )
147144 img_info ['ann' ] = dict (seg_map = seg_map )
148145 img_infos .append (img_info )
149146
@@ -165,6 +162,8 @@ def get_ann_info(self, idx):
165162 def pre_pipeline (self , results ):
166163 """Prepare results dict for pipeline."""
167164 results ['seg_fields' ] = []
165+ results ['img_prefix' ] = self .img_dir
166+ results ['seg_prefix' ] = self .ann_dir
168167 if self .custom_classes :
169168 results ['label_map' ] = self .label_map
170169
@@ -225,8 +224,9 @@ def get_gt_seg_maps(self):
225224 """Get ground truth segmentation maps for evaluation."""
226225 gt_seg_maps = []
227226 for img_info in self .img_infos :
227+ seg_map = osp .join (self .ann_dir , img_info ['ann' ]['seg_map' ])
228228 gt_seg_map = mmcv .imread (
229- img_info [ 'ann' ][ ' seg_map' ] , flag = 'unchanged' , backend = 'pillow' )
229+ seg_map , flag = 'unchanged' , backend = 'pillow' )
230230 # modify if custom classes
231231 if self .label_map is not None :
232232 for old_id , new_id in self .label_map .items ():
0 commit comments