commit
e458c2c7a2
|
@ -97,10 +97,11 @@ def process_image(img,
|
||||||
max_text_length=None,
|
max_text_length=None,
|
||||||
tps=None,
|
tps=None,
|
||||||
infer_mode=False):
|
infer_mode=False):
|
||||||
if not infer_mode or char_ops.character_type == "en" or tps != None:
|
if infer_mode and char_ops.character_type == "ch" and not tps:
|
||||||
norm_img = resize_norm_img(img, image_shape)
|
|
||||||
else:
|
|
||||||
norm_img = resize_norm_img_chinese(img, image_shape)
|
norm_img = resize_norm_img_chinese(img, image_shape)
|
||||||
|
else:
|
||||||
|
norm_img = resize_norm_img(img, image_shape)
|
||||||
|
|
||||||
norm_img = norm_img[np.newaxis, :]
|
norm_img = norm_img[np.newaxis, :]
|
||||||
if label is not None:
|
if label is not None:
|
||||||
# char_num = char_ops.get_char_num()
|
# char_num = char_ops.get_char_num()
|
||||||
|
@ -109,7 +110,8 @@ def process_image(img,
|
||||||
logger.info(
|
logger.info(
|
||||||
"Warning in ppocr/data/rec/img_tools.py:line106: Wrong data type."
|
"Warning in ppocr/data/rec/img_tools.py:line106: Wrong data type."
|
||||||
"Excepted string with length between 1 and {}, but "
|
"Excepted string with length between 1 and {}, but "
|
||||||
"got '{}'. Label is '{}'".format(max_text_length, len(text),label))
|
"got '{}'. Label is '{}'".format(max_text_length,
|
||||||
|
len(text), label))
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
if loss_type == "ctc":
|
if loss_type == "ctc":
|
||||||
|
|
|
@ -53,7 +53,7 @@ class TextRecognizer(object):
|
||||||
imgC, imgH, imgW = self.rec_image_shape
|
imgC, imgH, imgW = self.rec_image_shape
|
||||||
assert imgC == img.shape[2]
|
assert imgC == img.shape[2]
|
||||||
if self.character_type == "ch":
|
if self.character_type == "ch":
|
||||||
imgW = int(math.ceil(32 * max_wh_ratio))
|
imgW = int((32 * max_wh_ratio))
|
||||||
h, w = img.shape[:2]
|
h, w = img.shape[:2]
|
||||||
ratio = w / float(h)
|
ratio = w / float(h)
|
||||||
if math.ceil(imgH * ratio) > imgW:
|
if math.ceil(imgH * ratio) > imgW:
|
||||||
|
|
Loading…
Reference in New Issue