Commit 1a3ae0c9 authored by Ilija Radosavovic's avatar Ilija Radosavovic Committed by Facebook Github Bot

Assert that image reads succeed

Reviewed By: rbgirshick

Differential Revision: D6871605

fbshipit-source-id: 284a9267645cb039c2b20b8ceab68309664b0133
parent f0d1b0ab
......@@ -134,9 +134,11 @@ class JsonDataset(object):
# Reference back to the parent dataset
entry['dataset'] = self
# Make file_name an abs path
entry['image'] = os.path.join(
im_path = os.path.join(
self.image_directory, self.image_prefix + entry['file_name']
)
assert os.path.exists(im_path), 'Image \'{}\' not found'.format(im_path)
entry['image'] = im_path
entry['flipped'] = False
entry['has_visible_keypoints'] = False
# Empty placeholders
......
......@@ -99,6 +99,8 @@ def _get_image_blob(roidb):
im_scales = []
for i in range(num_images):
im = cv2.imread(roidb[i]['image'])
assert im is not None, \
'Failed to read image \'{}\''.format(roidb[i]['image'])
if roidb[i]['flipped']:
im = im[:, ::-1, :]
target_size = cfg.TRAIN.SCALES[scale_inds[i]]
......
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