Skip to content

Instantly share code, notes, and snippets.

@tarun-ssharma
Forked from dansitu/convert.py
Last active April 22, 2022 02:44
Show Gist options
  • Save tarun-ssharma/6bbf1ffe1f1276a9603206a177c8fe0c to your computer and use it in GitHub Desktop.
Save tarun-ssharma/6bbf1ffe1f1276a9603206a177c8fe0c to your computer and use it in GitHub Desktop.
Convert to tflite with randomly picked representative dataset
# Load TensorFlow
import tensorflow as tf
# Set up the converter
converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir)
converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE]
# Perform conversion and output file
tflite_quant_model = converter.convert()
output_dir.write_bytes(tflite_quant_model)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment