diff --git a/mmdet/datasets/custom.py b/mmdet/datasets/custom.py
index d596943f5dca668f99a61aecce535b2c944a915e..84a01913cc91c53b689cb464d48c2198a9f97657 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 cb5ce387e0d6eaa762a6b3eb72671dc05a804b63..90fb97c6ae98d6e04c044c81d8fd925959383858 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))