Skip to content

Commit

Permalink
fix onnx for dynamic shape (PaddlePaddle#8812)
Browse files Browse the repository at this point in the history
  • Loading branch information
tink2123 committed Jan 10, 2023
1 parent 57e4b88 commit ff947d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion tools/infer/predict_det.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ def __init__(self, args):

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]
Expand Down
5 changes: 3 additions & 2 deletions tools/infer/predict_rec.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,10 @@ def resize_norm_img(self, img, max_wh_ratio):
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:
Expand Down

0 comments on commit ff947d8

Please sign in to comment.