Conversion Keras model to Core ML Error

I am using Core Ml Conversion tool to convert style transfer model exists here https://jayanthkoushik.github.io/neural_style.html


Conversion is done using this code :

import coremltools coreml_model = coremltools.converters.keras.convert('stained_glass.h5',
                                                                        input_names='image',
                                                                        image_input_names='image', 
                                                                        output_names='grid',
                                                                        image_scale=1/255)

Error Received is not descriptive to what is the problem

Traceback (most recent call last): File "/home/deeplearning/Desktop/PythonScripts/PreTrained_transfer.py", 
line 7, in <module> image_scale=1/255) File "/usr/local/lib/python2.7/dist-packages/coremltools/converters/keras/_keras_converter.py",
line 504, in convert predicted_probabilities_output = predicted_probabilities_output
File "/usr/local/lib/python2.7/dist-packages/coremltools/converters/keras/_keras2_converter.py",
line 152,in _convert model = _keras.models.load_model(model) File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 238,
in load_model raise ValueError('No model found in config file.') ValueError: No model found in config file.



Thanks, in Advance

Replies

I have found that this model is weight model that is saved by model.save_weights('stained_glass.h5')

How to convert weight models to mlmodel ?



Any help?

Try to load the model in Keras first to check that your model was saved correctly


from keras.models import load_model
model = load_model('my_model.h5')


Once you have the model in memory, try converting it to CoreML