Skip to content

Instantly share code, notes, and snippets.

@sarkerrabi
Last active July 10, 2023 13:54
Show Gist options
  • Save sarkerrabi/b09a8f9a2fdc55355716f902964f8ef0 to your computer and use it in GitHub Desktop.
Save sarkerrabi/b09a8f9a2fdc55355716f902964f8ef0 to your computer and use it in GitHub Desktop.
To convert an ML(Machine Learning) module like .h5 to tflite
import tensorflow as tf
#store .h5 file in your .py folder
#load h5 module
model=tf.keras.models.load_model('sample_file.h5')
tflite_converter = tf.lite.TFLiteConverter.from_keras_model(model)
#convert
tflite_model = tflite_converter.convert()
open("tf_lite_model.tflite", "wb").write(tflite_model)
#done convertion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment