From 3f824f00bc74e16bfc25186b994579db6a59b29c Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Fri, 10 Jul 2020 10:40:10 +0800 Subject: [PATCH 1/3] modify normalization of db_process to speed up --- ppocr/data/det/db_process.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ppocr/data/det/db_process.py b/ppocr/data/det/db_process.py index cdb8efc2..b64b8c8d 100644 --- a/ppocr/data/det/db_process.py +++ b/ppocr/data/det/db_process.py @@ -194,8 +194,12 @@ class DBProcessTest(object): img_std = [0.229, 0.224, 0.225] im = im.astype(np.float32, copy=False) im = im / 255 - im -= img_mean - im /= img_std + im[:, :, 0] -= img_mean[0] + im[:, :, 1] -= img_mean[1] + im[:, :, 2] -= img_mean[2] + im[:, :, 0] /= img_std[0] + im[:, :, 1] /= img_std[1] + im[:, :, 2] /= img_std[2] channel_swap = (2, 0, 1) im = im.transpose(channel_swap) return im From 29aea6a206d5ecfec1e7b0addab1792a0833e47e Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Fri, 10 Jul 2020 15:24:00 +0800 Subject: [PATCH 2/3] delete warning when label length greater than setting length --- ppocr/data/rec/img_tools.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ppocr/data/rec/img_tools.py b/ppocr/data/rec/img_tools.py index 76c4315a..6e3577aa 100755 --- a/ppocr/data/rec/img_tools.py +++ b/ppocr/data/rec/img_tools.py @@ -359,11 +359,6 @@ def process_image(img, # char_num = char_ops.get_char_num() text = char_ops.encode(label) if len(text) == 0 or len(text) > max_text_length: - logger.info( - "Warning in ppocr/data/rec/img_tools.py:line106: Wrong data type." - "Excepted string with length between 1 and {}, but " - "got '{}'. Label is '{}'".format(max_text_length, - len(text), label)) return None else: if loss_type == "ctc": From 13e59395cc1b0cfaa7f81a271f32e0fc83c07e6b Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Fri, 10 Jul 2020 15:39:42 +0800 Subject: [PATCH 3/3] add warning when label length greater than setting length --- ppocr/data/rec/img_tools.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ppocr/data/rec/img_tools.py b/ppocr/data/rec/img_tools.py index 6e3577aa..d41abd9b 100755 --- a/ppocr/data/rec/img_tools.py +++ b/ppocr/data/rec/img_tools.py @@ -359,6 +359,11 @@ def process_image(img, # char_num = char_ops.get_char_num() text = char_ops.encode(label) if len(text) == 0 or len(text) > max_text_length: + logger.info( + "Warning in ppocr/data/rec/img_tools.py:line362: Wrong data type." + "Excepted string with length between 1 and {}, but " + "got '{}'. Label is '{}'".format(max_text_length, + len(text), label)) return None else: if loss_type == "ctc":