Skip to content

Instantly share code, notes, and snippets.

@amansrivastava17
Created November 12, 2019 07:17
Show Gist options
  • Select an option

  • Save amansrivastava17/d91c5345c7945d69430e16cbd84e9795 to your computer and use it in GitHub Desktop.

Select an option

Save amansrivastava17/d91c5345c7945d69430e16cbd84e9795 to your computer and use it in GitHub Desktop.

Revisions

  1. amansrivastava17 created this gist Nov 12, 2019.
    7 changes: 7 additions & 0 deletions convert_to_tflite.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    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.')