In order to convert TensorFlow checkpoints and GraphDef to a TensorFlow Lite FlatBuffer:
- Freeze the checkpoints and graph using freeze_graph.py
- Convert the frozen graph to a TensorFlow Lite FlatBuffer using
TOCO.
Your freeze_graph.py
command will look similar to the following:
freeze_graph -- \
--input_graph=output_graph.pb \
--input_binary=true \
--input_checkpoint=checkpoint \
--output_graph=frozen_graph.pb \
--output_node_names= MobilenetV1/Predictions/Softmax
You can use either TocoConverter
(Python API) or tflite_convert
(command line tool) with your model. TocoConverter
accepts a tf.Session, frozen graph def, SavedModel directory or a Keras model file. tflite_convert
accepts the later three formats.
When using TOCO, specify the output_file
parameter with a .tflite
extension.