load_model: No model found in config file
See original GitHub issueI converted a few caffe models to Keras using the MarcBS fork. However, upon attempting to load the models, I get this error:
>>> x = keras.models.load_model('vgg16_weights.h5') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/tigress/dchouren/thesis/git/keras-marcbs/keras/models.py", line 138, in load_model raise ValueError('No model found in config file.') ValueError: No model found in config file.
I then downloaded a pretrained VGG16 model from here: https://gist.github.com/baraldilorenzo/07d7802847aaad0a35d3
Attempts to load this model were met with the same error.
Using latest version of Keras (cloned and used python setup.py develop) with Python 3.5.2 and Theano backend. Have not changed anything in Keras develop except for adding some print lines. I am using the non-forked Keras when I attempted to load these models, although the forked version also fails with the same error.
Anyone see this before?
Issue Analytics
- State:
- Created 7 years ago
- Comments:9
Top Related StackOverflow Question
One possible and somewhat obvious cause of this (thanks yxfGrace for the hint) is saving a model using the Checkpoint callback with “save_weights_only” set to True. In this case you would need to instantiate the model using your original code then load the weights from file, as the model structure details won’t be serialised, just the weights. This was the cause of this error for me, at least. To fix so you can use load_model, you can set “save_weights_only” to False when setting up the callback.
try to use model.save(), might solve the prob!