Emanuel Covaci
Emanuel Covaci

Reputation: 101

Convert onnx model to keras

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'"

ONNX Model Input: input_1

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'

Upvotes: 5

Views: 14604

Answers (1)

Emanuel Covaci
Emanuel Covaci

Reputation: 101

The problem was resolved in the new version of the onnx2keras library You can see the issue on the GitHub https://github.com/nerox8664/onnx2keras/issues/23

Upvotes: 1

Related Questions