Converting TensorFlow .pb Model to .tflite Model: A Step-by-Step Guide

Mustafa Celik
2 min readAug 10, 2023

In the world of machine learning, model deployment is a crucial step. TensorFlow provides a convenient way to save models in the SavedModel format (.pb) for deployment, but sometimes we need to convert them into TensorFlow Lite format (.tflite) to deploy them on resource-constrained devices. In this tutorial, we’ll walk through the process of converting a .pb model to .tflite using Python and TensorFlow.


1. Basic knowledge of TensorFlow and Python.
2. TensorFlow installed (version 2.x).

Steps to Convert .pb to .tflite

Step 1: Load the .pb Model
First, make sure you have the .pb model file saved on your system. If not, you can train a TensorFlow model and save it using the SavedModel format. We’ll assume the .pb file is located at `”path/to/saved_model.pb”`.

import tensorflow as tf
# Load the .pb file
converter = tf.lite.TFLiteConverter.from_saved_model("path/to/saved_model.pb")

Step 2: Convert the Model
Next, convert the loaded .pb model to .tflite format using the converter’s `convert()` method.

# Convert the model
tflite_model = converter.convert()