Skip to content

Instantly share code, notes, and snippets.

@amansrivastava17
Created November 12, 2019 07:17
Show Gist options
  • Save amansrivastava17/d91c5345c7945d69430e16cbd84e9795 to your computer and use it in GitHub Desktop.
Save amansrivastava17/d91c5345c7945d69430e16cbd84e9795 to your computer and use it in GitHub Desktop.
def convert_model_to_tflite(keras_model_path):
tf.logging.set_verbosity( tf.logging.ERROR )
converter = tf.contrib.lite.TFLiteConverter.from_keras_model_file(keras_model_path )
converter.post_training_quantize = True
tflite_buffer = converter.convert()
open( 'model.tflite' , 'wb' ).write( tflite_buffer )
print( 'TFLite model created.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment