From 72e501dab869e45d1f2d1a625eb5b84f0adfbd5f Mon Sep 17 00:00:00 2001 From: Seongjoon Lee Date: Wed, 19 Oct 2022 22:39:19 +0900 Subject: [PATCH] Fix Python error due to Python version --- python/TFLiteBufferConverter.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/TFLiteBufferConverter.py b/python/TFLiteBufferConverter.py index cecc28b..7c9ce90 100644 --- a/python/TFLiteBufferConverter.py +++ b/python/TFLiteBufferConverter.py @@ -1,13 +1,16 @@ import tensorflow as tf -tf.logging.set_verbosity( tf.logging.ERROR ) +tf.compat.v1.logging.set_verbosity( tf.compat.v1.logging.ERROR ) keras_model_path = input( "Enter Keras model file path > " ) -converter = tf.lite.TFLiteConverter.from_keras_model_file( keras_model_path ) +keras_model = tf.keras.models.load_model(keras_model_path) +converter = tf.lite.TFLiteConverter.from_keras_model(keras_model) +#converter = tf.lite.TFLiteConverter.from_keras_model( keras_model_path ) + converter.post_training_quantize = True tflite_buffer = converter.convert() open( 'android/model.tflite' , 'wb' ).write( tflite_buffer ) -print( 'TFLite model created.') \ No newline at end of file +print( 'TFLite model created.')