I have tried various ways to convert my Keras model to core ml using core ml tools, but it gives me this error.
Keras layer '' not supported.
I am trying to convert .h5 model to core ml so that I can use it in my app but it gives me some errors which I am not able to solve. Also, I have tried converting .h5 model to PB(frozen graph) but got errors over there.
This is how my model looks.
img_input = layers.Input(shape=(224, 224, 3))
seed = 230
numpy.random.seed(seed)
x = layers.Conv2D(16, 3, activation='relu')(img_input)
x = layers.MaxPooling2D(2)(x)
x = layers.Conv2D(32, 3, activation='relu')(x)
x = layers.MaxPooling2D(2)(x)
x = layers.Flatten()(x)
x = layers.Dense(128, activation='relu')(x)
x = layers.Dropout(0.4)(x)
output = layers.Dense(3, activation='softmax')(x)
model = Model(img_input, output)
model.compile(loss='sparse_categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
this is the code i found over the web to convert Keras model to core ml tools.
import keras import coremltools
fcn_mlmodel = coremltools.converters.keras.convert( model, input_names = 'image', image_input_names = 'image', output_names = 'class_label' )
fcn_mlmodel.input_description['image']="Image size (224,224,3)"
fcn_mlmodel.output_description['class_label']=" Class label"
fcn_mlmodel.save("Test_my.mlmodel")
Err: Keras layer '' not supported. –
Can't recreate your problem, copied everything. Maybe it's a problem with your versions:
pip install -U coremltools==3.0b6 tensorflow==1.13.1 keras==2.2.4
works good together.