From cfc166c91b44803eb421c9142546a521a6748056 Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Fri, 19 Jun 2020 13:16:50 +0800 Subject: [PATCH] add error message when img is None --- ppocr/data/det/dataset_traversal.py | 3 +++ ppocr/data/det/db_process.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/ppocr/data/det/dataset_traversal.py b/ppocr/data/det/dataset_traversal.py index d7c74078..16866b0e 100644 --- a/ppocr/data/det/dataset_traversal.py +++ b/ppocr/data/det/dataset_traversal.py @@ -94,6 +94,9 @@ class EvalTestReader(object): batch_outs = [] for img_path in img_list: img = cv2.imread(img_path) + if img is None: + logger.info("{} does not exist!".format(img_path)) + continue if len(list(img.shape)) == 2 or img.shape[2] == 1: img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR) if img is None: diff --git a/ppocr/data/det/db_process.py b/ppocr/data/det/db_process.py index 0993324a..ee131501 100644 --- a/ppocr/data/det/db_process.py +++ b/ppocr/data/det/db_process.py @@ -104,6 +104,8 @@ class DBProcessTrain(object): if imgvalue is None: logger.info("{} does not exist!".format(img_path)) return None + if len(list(imgvalue.shape)) == 2 or imgvalue.shape[2] == 1: + imgvalue = cv2.cvtColor(imgvalue, cv2.COLOR_GRAY2BGR) data = self.make_data_dict(imgvalue, gt_label) data = AugmentData(data) data = RandomCropData(data, self.image_shape[1:]) -- GitLab