Saqib
Saqib

Reputation: 7432

Use CoreMLTools to generate models for iOS 11/12

We have a model trained using Keras, using the MobileNetV2 architecture.

We can use CoreMLTools to convert from the .H5 file to a .MLModel CoreML model.

However, with latest CoreMLTools (5.x) the resulting model only runs on iOS 13 and later, but our app supports iOS 11.

Is there a way to generate a iOS 11/12 compatible model with latest CoreMLTools?

We thought of trying to install older CoreMLTools (like 2.x) but for other reasons have had dependency issues installing that. But it feels there should be a way to specify CoreML version when converting the model?

Upvotes: 1

Views: 475

Answers (1)

Frank Krueger
Frank Krueger

Reputation: 71043

I would highly recommend working through your version dependencies and get an older version of coremltools working. I understand the difficulty there but I promise you all other paths will be more difficult.

Now the good news. CoreML models are just protocol buffers that you can easily load and manipulate yourself without coremltools. I keep a compiled version of their protocol spec in a library just for these kinds of tasks. You can get the PB spec here: https://github.com/apple/coremltools/tree/f19052c7f113740069bfac7b0291c5c6c9571ca6/mlmodel/format

Load up your iOS 11 model in a PB viewer, load up the iOS 13 version, and remove everything in the 13 version that’s not in 11. :-)

Thankfully CoreML models are pretty simple and I can guess that there’s just one version flag set that you need to reset.

Upvotes: 1

Related Questions