Marij Khan
Marij Khan

Reputation: 161

How do I convert a Tensorflow model to .mlmodel?

I want to convert a Tensorflow model with the following structure to a .mlmodel file for use in an iOS app:

cub_image_experiment/
   logdir/
       val_summaries/
       test_summaries/
       finetune/
          val_summaries/
   cmds.txt
   config_train.yaml
   config_test.yaml

I'm following this tutorial: https://github.com/visipedia/tf_classification/wiki/CUB-200-Image-Classification However, I'm having trouble understanding the structure of the project. Which files are important and how do I convert all the separate config files and everything into a single .mlmodel file so that I can use in my application?

I've looked online and all I could find was how to convert .caffemodel to .mlmodel or .pb file to .mlmodel. These are all single files, however my project has multiple files. I found a tutorial on how to convert a tf model into a single .pb file, however, that model's structure was different and it did not contain any yaml files. My project is not focused on creating a model at the moment, but merely integrating a model into an iOS app. I found this model interesting for an app idea and wanted to know if it can be integrated. If there are any tutorials out there that might help me in this sort of problem please let me know.

Upvotes: 0

Views: 1474

Answers (1)

Matthijs Hollemans
Matthijs Hollemans

Reputation: 7892

None of that stuff is used by the Core ML model. The yaml files etc are used only to train the TF model.

All you need to provide is a frozen graph (a .pb file) and then convert it to an mlmodel using tfcoreml.

It looks like your project doesn't have a frozen graph but checkpoints. There is a TF utility that you can use to convert the checkpoint to a frozen graph, see https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/freeze_graph.py

Upvotes: 1

Related Questions