fix infer shape

This commit is contained in:
tink2123 2021-08-25 09:41:16 +00:00
parent 7488bc1db5
commit 22b57d632d
1 changed files with 2 additions and 3 deletions

View File

@ -88,9 +88,8 @@ class TextRecognizer(object):
def resize_norm_img(self, img, max_wh_ratio): def resize_norm_img(self, img, max_wh_ratio):
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": max_wh_ratio = max(max_wh_ratio, imgW / imgH)
max_wh_ratio = max(max_wh_ratio, imgW / imgH) imgW = int((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: