gmalivenko / onnx2keras

Convert ONNX model graph to Keras model format.
MIT License
195 stars 116 forks source link

KeyError: 'group' #31

Closed emanuelcovaci closed 4 years ago

emanuelcovaci commented 4 years ago

I tried to convert the LaneNet-Lane-Detection model (https://github.com/MaybeShewill-CV/lanenet-lane-detection) from TensorFlow to ONNX and then to Keras.

But I received the following error:

  File ".../PycharmProjects/ONNX/lanenet/onnx2Keras.py", line 6, in <module>
    k_model = onnx_to_keras(onnx_model, ['lanenet/input_tensor'],name_policy='renumerate')
  File "...\anaconda3\lib\site-packages\onnx2keras\converter.py", line 174, in onnx_to_keras
    keras_names
  File "...\tools\anaconda3\lib\site-packages\onnx2keras\convolution_layers.py", line 212, in convert_convtranspose
    if params['group'] > 1:
KeyError: 'group'

Other details: I printed the value of params

{'dilations': [1, 1], 'strides': [2, 2], 'kernel_shape': [4, 4], 'output_shape': [32, 64], 'change_ordering': False, 'name_policy': 'renumerate'}

In params I don't have 'group' , 'pads'

You can access the ONNX model here: https://drive.google.com/file/d/1RvCjc05T5kRoy6VOBS4o9vZV6hQkOOjl/view?usp=sharing

I commented the line 213-214 to pass the if statement if params['group'] > 1: but the next error received is:

Traceback (most recent call last):
  File ".../ONNX/lanenet/onnx2Keras.py", line 6, in <module>
    k_model = onnx_to_keras(onnx_model, ['lanenet/input_tensor'],name_policy='renumerate')
  File "...\anaconda3\lib\site-packages\onnx2keras\converter.py", line 174, in onnx_to_keras
    keras_names
  File "...\tools\anaconda3\lib\site-packages\onnx2keras\convolution_layers.py", line 237, in convert_convtranspose
    input_0.set_shape(input_0._keras_shape)
AttributeError: 'Tensor' object has no attribute '_keras_shape'
gmalivenko commented 4 years ago

Hello @emanuelcovaci. Please, upgrade your library version to the latest. pip install --upgrade onnx2keras

emanuelcovaci commented 4 years ago

Thanks @nerox8664!