load_model: No model found in config file

See original GitHub issue

I 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:closed
  • Created 7 years ago
  • Comments:9

github_iconTop GitHub Comments

16reactions
tomcwalkercommented, Dec 9, 2017

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.

2reactions
yzho0907commented, Aug 9, 2018

try to use model.save(), might solve the prob!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to load model from .h5 file · Issue #6937 - GitHub
from keras.models import load_model base_model=load_model('alexnet_weights.h5'). I ended up with. ValueError: No model found in config file.
Read more >
Error while importing VGG16 h5 file ValueError: No model ...
I was able to recreate the issue using your code and downloaded weights file mentioned by you. I am not sure about the...
Read more >
Model saved into an unique .h5 file (or TensorflowLight)
Hi there, I saved the model using the following code, ... ValueError: No model config found in the file at <tensorflow.python.platform.gfile.
Read more >
Problems loading h5 model - TensorFlow Forum
raise ValueError('No model found in config file.') if hasattr(model_config, 'decode'):; model_config = model_config.decode('utf-8') ...
Read more >
Exception occurs when loading keras model using load_model
When I tried to load the model using **load_model**, I'm getting this exception **ValueError: No model found in config file.**.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found