keras-onnx
keras-onnx copied to clipboard
Unable to convert a keras model to onnx
I've trained a mobilenetv2 model on a custom dataset using Keras. After training I saved my model using model.save
, I tried converting it to onnx using this script:
from tensorflow.python.keras.models import load_model
import onnx
import keras2onnx
onnx_model_name = 'sw-mobilenetv2.onnx'
model = load_model('swmodel.h5')
onnx_model = keras2onnx.convert_keras(model, model.name)
onnx.save_model(onnx_model, onnx_model_name)
and I recieve this error :
Exception has occurred: OSError
SavedModel file does not exist at: model.h5/{saved_model.pbtxt|saved_model.pb}
File "/home/marwen/MobileNetV2/keras-onnx.py", line 7, in <module>
model = load_model('model.h5')
The error occurs in load_model
which is keras API, seems not related to keras2onnx issue.
This error mostly occurs because you do not have the file in the directory. Please check if the file is present and the name is right.