AxisCommunications / onnx-to-keras

Convert onnx models exported from pytorch to tensorflow keras models with focus on performace and highleve compatibility.
MIT License
25 stars 13 forks source link

Error occurred when trying to convert Shape operator #46

Open t123yh opened 2 years ago

t123yh commented 2 years ago

Describe the bug

Error occurred when trying to convert this model.

To reproduce

  1. Convert this file: https://drive.google.com/file/d/1C9oxLAHe-RjophSigy360ccAashUan_n/view?usp=sharing

Screenshots

Traceback (most recent call last):
  File "onnx2keras.py", line 770, in <module>
    Fire(main)
  File "/usr/local/lib/python3.7/dist-packages/fire/core.py", line 141, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/usr/local/lib/python3.7/dist-packages/fire/core.py", line 471, in _Fire
    target=component.__name__)
  File "/usr/local/lib/python3.7/dist-packages/fire/core.py", line 681, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "onnx2keras.py", line 758, in main
    model = onnx2keras(onnx.load(infile), make_tflite_compatible)
  File "onnx2keras.py", line 699, in onnx2keras
    output_tensors = ops.make_op(node.op_type, inputs, attrs)
  File "onnx2keras.py", line 18, in make_op
    return getattr(self, 'op_' + op_type.lower())(*inputs, **attrs)
  File "onnx2keras.py", line 492, in op_shape
    shape = list(map(int, x.shape))
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
95hali74 commented 1 year ago

Hi,

The reason seems to be that you model have dynamic batch size, could you export a onnx model with fixed batch size and see if that fixes the problem?