未验证 提交 ff947d89 编写于 作者: X xiaoting 提交者: GitHub

fix onnx for dynamic shape (#8812)

上级 57e4b882
...@@ -143,7 +143,9 @@ class TextDetector(object): ...@@ -143,7 +143,9 @@ class TextDetector(object):
if self.use_onnx: if self.use_onnx:
img_h, img_w = self.input_tensor.shape[2:] 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] = { pre_process_list[0] = {
'DetResizeForTest': { 'DetResizeForTest': {
'image_shape': [img_h, img_w] 'image_shape': [img_h, img_w]
......
...@@ -173,9 +173,10 @@ class TextRecognizer(object): ...@@ -173,9 +173,10 @@ class TextRecognizer(object):
imgW = int((imgH * max_wh_ratio)) imgW = int((imgH * max_wh_ratio))
if self.use_onnx: if self.use_onnx:
w = self.input_tensor.shape[3:][0] 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 imgW = w
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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册