Convert TensorFlow models

This page describes how to convert a TensorFlow model to a LiteRT model (an optimized FlatBuffer format identified by the .tflite file extension) using the LiteRT converter.

Conversion workflow

The diagram below illustrations the high-level workflow for converting your model:

TFLite converter workflow

Figure 1. Converter workflow.

You can convert your model using one of the following options:

  1. Python API (recommended): This allows you to integrate the conversion into your development pipeline, apply optimizations, add metadata and many other tasks that simplify the conversion process.
  2. Command line: This only supports basic model conversion.

Python API

Helper code: To learn more about the LiteRT converter API, run print(help(tf.lite.TFLiteConverter)).

Convert a TensorFlow model using tf.lite.TFLiteConverter. A TensorFlow model is stored using the SavedModel format and is generated either using the high-level tf.keras.* APIs (a Keras model) or the low-level tf.* APIs (from which you generate concrete functions). As a result, you have the following three options (examples are in the next few sections):