From 0e1ef228476f490d819834376be6f11981f1e0f2 Mon Sep 17 00:00:00 2001 From: jerrywgz Date: Thu, 17 Jan 2019 18:10:53 +0800 Subject: [PATCH] fix hang when load error in faster_rcnn (#1666) * fix hang when load error in faster_rcnn --- fluid/PaddleCV/faster_rcnn/data_utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fluid/PaddleCV/faster_rcnn/data_utils.py b/fluid/PaddleCV/faster_rcnn/data_utils.py index 12858f1b..4d63b626 100644 --- a/fluid/PaddleCV/faster_rcnn/data_utils.py +++ b/fluid/PaddleCV/faster_rcnn/data_utils.py @@ -28,6 +28,7 @@ from __future__ import unicode_literals import cv2 import numpy as np from config import cfg +import os def get_image_blob(roidb, mode): @@ -43,8 +44,11 @@ def get_image_blob(roidb, mode): target_size = cfg.TEST.scales[0] max_size = cfg.TEST.max_size im = cv2.imread(roidb['image']) - assert im is not None, \ - 'Failed to read image \'{}\''.format(roidb['image']) + try: + assert im is not None + except AssertionError as e: + print('Failed to read image \'{}\''.format(roidb['image'])) + os._exit(0) if roidb['flipped']: im = im[:, ::-1, :] im, im_scale = prep_im_for_blob(im, cfg.pixel_means, target_size, max_size) -- GitLab