From 80714b008dcc1d4053c8e5459f6a75d063944932 Mon Sep 17 00:00:00 2001 From: Bai Yifan Date: Thu, 2 Apr 2020 17:49:43 +0800 Subject: [PATCH] fix reader hang issue when data path is not valid (#205) --- demo/imagenet_reader.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/demo/imagenet_reader.py b/demo/imagenet_reader.py index 01aa65a50ea4d5..947fd023b9c6ee 100644 --- a/demo/imagenet_reader.py +++ b/demo/imagenet_reader.py @@ -100,7 +100,11 @@ def random_color(img, lower=0.5, upper=1.5): def process_image(sample, mode, color_jitter, rotate): img_path = sample[0] - img = Image.open(img_path) + try: + img = Image.open(img_path) + except: + print(img_path, "not exists!") + return None if mode == 'train': if rotate: img = rotate_image(img) img = random_crop(img, DATA_DIM)