Nikhil Chandra
Nikhil Chandra

Reputation: 163

How to convert tensorflow-lite model to coreml .mlmodel

I am currently using google firebase integrated with my ios app. I am using MLKit in my app with a local TensorFlow lite model as an image classifier.

But having Xcode 9, I am unable to do this with my app as autoMLVision is new and requires xcode 10.1. Now I think the best thing to do is to convert the TensorFlow lite model, I trained in google firebase and downloaded, to a .mlmodel and use Core ML for image classification.

How would I go about doing this conversion. If you have an alternate way of solving this version problem, please share. Tell me if you need more information.

Upvotes: 4

Views: 2740

Answers (1)

Matthijs Hollemans
Matthijs Hollemans

Reputation: 7892

As far as I know, you cannot currently convert a TFLite model directly to Core ML. You can only convert frozen .pb models using tfcoreml.

One option might be to convert the TFLite model back to a frozen .pb model (not sure if there are conversion tools that let you do this).

Another option is to do the conversion by hand, using coremltools' NeuralNetworkBuilder. You will need to read the TFLite file, extract the weights, potentially transpose them into the order that Core ML expects, and then build the Core ML version of the model using NeuralNetworkBuilder.

Upvotes: 3

Related Questions