gmalivenko / onnx2keras

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

AttributeError: Number of inputs is not equal 1 for slice layer #30

Open emanuelcovaci opened 4 years ago

emanuelcovaci commented 4 years ago

Hi @nerox8664!

I tried to convert an ONNX model to Keras, but I received the following error

Traceback (most recent call last):
  File "onnx2Keras.py", line 6, in <module>
    k_model = onnx_to_keras(onnx_model, ['input/input_data'],name_policy='renumerate')
  File "...\onnx2keras-env\lib\site-packages\onnx2keras\converter.py", line 174, in onnx_to_keras
    keras_names
  File "...\onnx2keras-env\lib\site-packages\onnx2keras\reshape_layers.py", line 264, in convert_slice
    raise AttributeError('Number of inputs is not equal 1 for slice layer')
AttributeError: Number of inputs is not equal 1 for slice layer

I converted this model https://github.com/YunYang1994/tensorflow-yolov3 from Tensorflow to ONNX and now I need the model in Keras.

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

Thanks!

andreimihalcea97 commented 4 years ago

Hi @nerox8664 @emanuelcovaci !

I also tried to convert the same ONNX model to Keras and I received exactly the same error. The slice layer received 4 inputs, three of which seem to be weights.

Thanks!

gmalivenko commented 4 years ago

Hello @emanuelcovaci @andreimihalcea97.

I fixed some errors related to slice layer. It now works with 4 inputs (with assumption that axes are [0, 1, ... ndims] array).

Unfortunatelly, @emanuelcovaci, your model still can't be converted due to ONNX Resize layer

dsuthar-nvidia commented 4 years ago

@nerox8664 The onnx-tensorflow has a resize layer implementation at https://github.com/onnx/onnx-tensorflow/blob/master/onnx_tf/handlers/backend/resize.py

Can you use this and add it to onnx2keras?