I have a keras model (TF 2.*), and I want to convert it to mlmodel with iOS version of 12.
According to coremltools 4 release notes:
"To deploy the Core ML model to a target that is iOS12, macOS 10.13, watchOS 5, tvOS 12, or an older version, use coremltools 3 and tfcoreml 1."
tfcoreml is suitable for TF 1.* only, so I understand I need to use coremltools version 3.*.
I am trying coremltools version 3.2, and I would like to use this function [coremltools.converters.keras.convert][2].
I start with a simple try, using fresh venv with coremltools==3.2, tensorflow==2.4.1, keras==2.4.3:
base_model = load_model(keras_model_p)
coreml_model = coremltools.converters.keras.convert(model)
But I receive the following error:
TypeError: Keras layer of type <class 'tensorflow.python.keras.engine.functional.Functional'> is not supported.
I tried to change the Functional part, changing from:
base_model2 = load_model(keras_model_p)
top_model2 = Sequential()
top_model2.add(Permute((3, 1, 2)))
model2 = Model(inputs=base_model2.input, outputs=top_model2(base_model2.output))
to
base_model = load_model(keras_model_p)
model = Sequential()
model.add(base_model)
model.add(Permute((3, 1, 2)))
and receive the error:
TypeError: 'InputLayer' object is not iterable
The second try is using the first TF 2.* versions: tensorflow==2.0.0 and keras==2.3.0.
I execute the same but receive:
ValueError: Keras layer '<class 'tensorflow.python.keras.engine.input_layer.InputLayer'>' not supported.
How can I solve it?
Thanks