gmalivenko / onnx2keras

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

TypeError: unhashable type: 'google.protobuf.pyext._message.RepeatedScalarContaine' #23

Closed emanuelcovaci closed 5 years ago

emanuelcovaci commented 5 years ago

I try to convert an ONNX model to Keras, but when I call the conversion function I receive the following error message "TypeError: unhashable type: 'google.protobuf.pyext._message.RepeatedScalarContainer'"

You can see the ONNX Model here: https://ibb.co/sKnbxWY

import onnx2keras
from onnx2keras import onnx_to_keras
import keras
import onnx

onnx_model = onnx.load('onnxModel.onnx')
k_model = onnx_to_keras(onnx_model, ['input_1'])

keras.models.save_model(k_model,'kerasModel.h5',overwrite=True,include_optimizer=True)
File "C:/../onnx2Keras.py", line 7, in <module>
    k_model = onnx_to_keras(onnx_model, ['input_1'])
  File "..\site-packages\onnx2keras\converter.py", line 80, in onnx_to_keras
    weights[onnx_extracted_weights_name] = numpy_helper.to_array(onnx_w)
TypeError: unhashable type: 'google.protobuf.pyext._message.RepeatedScalarContainer'
gmalivenko commented 5 years ago

Hello @emanuelcovaci. Can you share your ONNX model so I can reproduce the error? In your error message I see the issue related to onnx weights loading, not to the model architecture, because actual conversion hasn't even started.

emanuelcovaci commented 5 years ago

Hello @nerox8664

Here you can find the model https://drive.google.com/open?id=1oQTzQ0BO6msO_djhbgsdvpaM22PLtn49

gmalivenko commented 5 years ago

Please, try to convert your model with updated version of the library. pip install --upgrade onnx2keras

Also, use name_policy='renumerate' parameter to fix naming error.

emanuelcovaci commented 5 years ago

It's working fine now. Thank you

ghost commented 4 years ago

I still have this error.

here is my onnx file if it can help: https://drive.google.com/file/d/17VOpLc3zWqjX8mqFWH2BRYYIY0v4dW5A/view?usp=sharing

mdhimes commented 4 years ago

I'm on the latest version via pip (0.0.22), and I am also getting this same error. Latest version of onnx (1.7.0) as well.

Pull request related to this issue: https://github.com/nerox8664/onnx2keras/pull/76