From bb98fafffbc57a50874b25e0a10402d3c76338b7 Mon Sep 17 00:00:00 2001 From: tink2123 Date: Fri, 16 Oct 2020 14:00:01 +0800 Subject: [PATCH] fix max_wh_ratio for predict --- tools/infer/predict_rec.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/infer/predict_rec.py b/tools/infer/predict_rec.py index 1989f524..7c942255 100755 --- a/tools/infer/predict_rec.py +++ b/tools/infer/predict_rec.py @@ -60,9 +60,10 @@ class TextRecognizer(object): self.loss_type = 'srn' self.char_ops = CharacterOps(char_ops_params) - def resize_norm_img(self, img, max_wh_ratio): + def resize_norm_img(self, img, wh_ratio): imgC, imgH, imgW = self.rec_image_shape assert imgC == img.shape[2] + max_wh_ration = max(wh_ratio, imgW * 1.0 / imgH) if self.character_type == "ch": imgW = int((32 * max_wh_ratio)) h, w = img.shape[:2] @@ -173,16 +174,14 @@ class TextRecognizer(object): for beg_img_no in range(0, img_num, batch_num): end_img_no = min(img_num, beg_img_no + batch_num) norm_img_batch = [] - max_wh_ratio = 0 for ino in range(beg_img_no, end_img_no): # h, w = img_list[ino].shape[0:2] h, w = img_list[indices[ino]].shape[0:2] wh_ratio = w * 1.0 / h - max_wh_ratio = max(max_wh_ratio, wh_ratio) for ino in range(beg_img_no, end_img_no): if self.loss_type != "srn": norm_img = self.resize_norm_img(img_list[indices[ino]], - max_wh_ratio) + wh_ratio) norm_img = norm_img[np.newaxis, :] norm_img_batch.append(norm_img) else: -- GitLab