From 1c8cddf46f85d4359881a16a8014121f3aeec9de Mon Sep 17 00:00:00 2001 From: tink2123 Date: Tue, 30 Jun 2020 13:59:59 +0800 Subject: [PATCH] fix resize norm for ch --- ppocr/data/rec/img_tools.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ppocr/data/rec/img_tools.py b/ppocr/data/rec/img_tools.py index 3ca20f3f..ef4e4e56 100755 --- a/ppocr/data/rec/img_tools.py +++ b/ppocr/data/rec/img_tools.py @@ -53,6 +53,7 @@ def resize_norm_img(img, image_shape): def resize_norm_img_chinese(img, image_shape): imgC, imgH, imgW = image_shape # todo: change to 0 and modified image shape + imgC = 3 max_wh_ratio = 0 h, w = img.shape[0], img.shape[1] ratio = w * 1.0 / h @@ -97,10 +98,11 @@ def process_image(img, max_text_length=None, tps=None, infer_mode=False): - if not infer_mode and (char_ops.character_type == "en" or tps != None): - norm_img = resize_norm_img(img, image_shape) - else: + if infer_mode and char_ops.character_type == "ch" and not tps: norm_img = resize_norm_img_chinese(img, image_shape) + else: + norm_img = resize_norm_img(img, image_shape) + norm_img = norm_img[np.newaxis, :] if label is not None: # char_num = char_ops.get_char_num() -- GitLab