onnx / keras-onnx

Convert tf.keras/Keras models to ONNX
Apache License 2.0
379 stars 110 forks source link

AttributeError: 'MaskRCNN' object has no attribute 'layers' #714

Closed RyuAmakaze closed 3 years ago

RyuAmakaze commented 3 years ago

This error is similar to #592 I'm trying to convert an .h5 file trained by maskRCNN to onnx.

When I try to convert a MaskRCNN model with keras2onnx.convert_keras, I encounter the error AttributeError: 'MaskRCNN' object has no attribute 'outputs'

So I upgraded the version of keras2onnx to 1.8.0. I upgraded keras2onnx to version 1.8.0, and got the following error message. AttributeError: 'MaskRCNN' object has no attribute 'layers'

Also, I would like to know if there is another good way to convert .h5 files trained with MaskRCNN to onnx.  Help me! ><

jiafatom commented 3 years ago

Could you try tensorflow 2.2.0?

RyuAmakaze commented 3 years ago

Already done it and same error. But I can do your tutorial "TensorFlow_Keras_MNIST.ipynb" :)

I think the biggest trouble is that MaskRCNN uses model.save_weights() instead of model.save() to save the keras model(.h5). Keras2onnx can convert ".h5 files" saved by model.save_weights() to .onnx?

RyuAmakaze commented 3 years ago

Since MaskRCNN is a wrapper around the keras model, it seems that the code needs to look like the following.

keras2onnx.convert_keras(model.keras_model, name)