From e68c3d907b436c5a84d4177710a89e91c4e5957c Mon Sep 17 00:00:00 2001
From: Matthew Dawkins <matthew.d.dawkins@gmail.com>
Date: Wed, 23 Oct 2019 08:56:12 -0400
Subject: [PATCH] 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
---
 mmdet/datasets/custom.py            |  2 +-
 mmdet/datasets/pipelines/loading.py | 14 ++++++++++----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/mmdet/datasets/custom.py b/mmdet/datasets/custom.py
index d596943..84a0191 100644
--- a/mmdet/datasets/custom.py
+++ b/mmdet/datasets/custom.py
@@ -37,7 +37,7 @@ class CustomDataset(Dataset):
                  ann_file,
                  pipeline,
                  data_root=None,
-                 img_prefix=None,
+                 img_prefix='',
                  seg_prefix=None,
                  proposal_file=None,
                  test_mode=False):
diff --git a/mmdet/datasets/pipelines/loading.py b/mmdet/datasets/pipelines/loading.py
index cb5ce38..90fb97c 100644
--- a/mmdet/datasets/pipelines/loading.py
+++ b/mmdet/datasets/pipelines/loading.py
@@ -15,8 +15,11 @@ class LoadImageFromFile(object):
         self.to_float32 = to_float32
 
     def __call__(self, results):
-        filename = osp.join(results['img_prefix'],
-                            results['img_info']['filename'])
+        if results['img_prefix'] is not None:
+            filename = osp.join(results['img_prefix'],
+                                results['img_info']['filename'])
+        else:
+            filename = results['img_info']['filename']
         img = mmcv.imread(filename)
         if self.to_float32:
             img = img.astype(np.float32)
@@ -52,8 +55,11 @@ class LoadAnnotations(object):
         ann_info = results['ann_info']
         results['gt_bboxes'] = ann_info['bboxes']
         if len(results['gt_bboxes']) == 0 and self.skip_img_without_anno:
-            file_path = osp.join(results['img_prefix'],
-                                 results['img_info']['filename'])
+            if results['img_prefix'] is not None:
+                file_path = osp.join(results['img_prefix'],
+                                     results['img_info']['filename'])
+            else:
+                file_path = results['img_info']['filename']
             warnings.warn(
                 'Skip the image "{}" that has no valid gt bbox'.format(
                     file_path))
-- 
GitLab