Skip to content

Commit 116180f

Browse files
committed
update RecResizeNormForInfer to support padding=False, keep_ratio=True, target_width=None when online predict
1 parent 8d0861d commit 116180f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

mindocr/data/transforms/rec_transforms.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,14 +411,16 @@ def __call__(self, data):
411411
# tar_h, tar_w = self.targt_shape
412412
resize_h = self.tar_h
413413

414-
max_wh_ratio = self.tar_w / float(self.tar_h)
415-
416414
if not self.keep_ratio:
417415
assert self.tar_w is not None, "Must specify target_width if keep_ratio is False"
418416
resize_w = self.tar_w # if self.tar_w is not None else resized_h * self.max_wh_ratio
419417
else:
420418
src_wh_ratio = w / float(h)
421-
resize_w = math.ceil(min(src_wh_ratio, max_wh_ratio) * resize_h)
419+
if self.tar_w is not None:
420+
max_wh_ratio = self.tar_w / float(self.tar_h)
421+
resize_w = math.ceil(min(src_wh_ratio, max_wh_ratio) * resize_h)
422+
else:
423+
resize_w = math.ceil(src_wh_ratio * resize_h)
422424
resized_img = cv2.resize(img, (resize_w, resize_h), interpolation=self.interpolation)
423425

424426
# TODO: norm before padding

0 commit comments

Comments
 (0)