fix onnx for dynamic shape (#8812)

This commit is contained in:
xiaoting
2023-01-10 10:48:42 +08:00
committed by GitHub
parent 57e4b8829a
commit ff947d8960
2 changed files with 6 additions and 3 deletions
+3 -1
View File
@@ -143,7 +143,9 @@ class TextDetector(object):
if self.use_onnx:
img_h, img_w = self.input_tensor.shape[2:]
if img_h is not None and img_w is not None and img_h > 0 and img_w > 0:
if isinstance(img_h, str) or isinstance(img_w, str):
pass
elif img_h is not None and img_w is not None and img_h > 0 and img_w > 0:
pre_process_list[0] = {
'DetResizeForTest': {
'image_shape': [img_h, img_w]
+3 -2
View File
@@ -173,9 +173,10 @@ class TextRecognizer(object):
imgW = int((imgH * max_wh_ratio))
if self.use_onnx:
w = self.input_tensor.shape[3:][0]
if w is not None and w > 0:
if isinstance(w, str):
pass
elif w is not None and w > 0:
imgW = w
h, w = img.shape[:2]
ratio = w / float(h)
if math.ceil(imgH * ratio) > imgW: