In today’s article, I will briefly show you how to convert the Keras model (.h5) to Tensorflow-Lite (.tflite). This action allows you to use the model on Android and iOS.

The following code was tested on Tensorflow 1.13.

import tensorflow as tf

keras_model_path = 'data/model.h5'
tflite_model_path = 'data/model.tflite'

converter = tf.lite.TFLiteConverter.from_keras_model_file(keras_model_path)
tflite_model = converter.convert()

with open(tflite_model_path, 'wb') as f
	f.write(tflite_model)