import tensorflow as tf


# fixed folder
saved_model_dir = "tf_cnn_model/1/"
target_dir = "tflite_cnn_model"

def convert_tflite():
    
    if not os.path.exists(target_dir):
        os.makedirs(target_dir)
        
    converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir)
    #converter.optimizations = [tf.lite.Optimize.DEFAULT]
    converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_LATENCY]

    tflite_model = converter.convert()

    with open(f"{target_dir}/tflite_model.tflite", "wb") as f:
        f.write(tflite_model)
        
def validation():
