Commit e68c3d90 authored by Matthew Dawkins's avatar Matthew Dawkins Committed by Kai Chen
Browse files

Fix issues with default 'img_prefix' value set to None when training (#1497)

* Still work if no img_prefix specified

* Update default param to be empty string
parent c514be0d
...@@ -37,7 +37,7 @@ class CustomDataset(Dataset): ...@@ -37,7 +37,7 @@ class CustomDataset(Dataset):
ann_file, ann_file,
pipeline, pipeline,
data_root=None, data_root=None,
img_prefix=None, img_prefix='',
seg_prefix=None, seg_prefix=None,
proposal_file=None, proposal_file=None,
test_mode=False): test_mode=False):
......
...@@ -15,8 +15,11 @@ class LoadImageFromFile(object): ...@@ -15,8 +15,11 @@ class LoadImageFromFile(object):
self.to_float32 = to_float32 self.to_float32 = to_float32
def __call__(self, results): def __call__(self, results):
if results['img_prefix'] is not None:
filename = osp.join(results['img_prefix'], filename = osp.join(results['img_prefix'],
results['img_info']['filename']) results['img_info']['filename'])
else:
filename = results['img_info']['filename']
img = mmcv.imread(filename) img = mmcv.imread(filename)
if self.to_float32: if self.to_float32:
img = img.astype(np.float32) img = img.astype(np.float32)
...@@ -52,8 +55,11 @@ class LoadAnnotations(object): ...@@ -52,8 +55,11 @@ class LoadAnnotations(object):
ann_info = results['ann_info'] ann_info = results['ann_info']
results['gt_bboxes'] = ann_info['bboxes'] results['gt_bboxes'] = ann_info['bboxes']
if len(results['gt_bboxes']) == 0 and self.skip_img_without_anno: if len(results['gt_bboxes']) == 0 and self.skip_img_without_anno:
if results['img_prefix'] is not None:
file_path = osp.join(results['img_prefix'], file_path = osp.join(results['img_prefix'],
results['img_info']['filename']) results['img_info']['filename'])
else:
file_path = results['img_info']['filename']
warnings.warn( warnings.warn(
'Skip the image "{}" that has no valid gt bbox'.format( 'Skip the image "{}" that has no valid gt bbox'.format(
file_path)) file_path))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment