gmalivenko / onnx2keras

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

ValueError: Exception encountered when calling layer "166_CHW" (type Lambda). #136

Open Akotkar23 opened 2 years ago

Akotkar23 commented 2 years ago

I am trying to convert ONNX model to Keras, but while converting getting the following error: ValueError: Exception encountered when calling layer "166_CHW" (type Lambda). Code `import onnx from onnx2keras import onnx_to_keras

Load ONNX model

onnx_model = onnx.load('best.onnx')

Call the converter (input - is the main model input name, can be different for your model)

k_model = onnx_to_keras(onnx_model, ['images']) ` Error trace: ValueError: Exception encountered when calling layer "166_CHW" (type Lambda).

Dimension 0 in both shapes must be equal, but are 639 and 638. Shapes are [639,638] and [638,638]. for '{{node 166_CHW/concat}} = ConcatV2[N=4, T=DT_FLOAT, Tidx=DT_INT32](Placeholder, Placeholder_1, Placeholder_2, Placeholder_3, 166_CHW/concat/axis)' with input shapes: [?,3,639,639], [?,3,638,639], [?,3,639,638], [?,3,638,638], [] and with computed input tensors: input[4] = <1>.

Call arguments received: • inputs=['tf.Tensor(shape=(None, 3, 639, 639), dtype=float32)', 'tf.Tensor(shape=(None, 3, 638, 639), dtype=float32)', 'tf.Tensor(shape=(None, 3, 639, 638), dtype=float32)', 'tf.Tensor(shape=(None, 3, 638, 638), dtype=float32)'] • mask=None • training=None