utils.py 440 B

12345678910111213
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. import tensorflow as tf
  4. import pathlib
  5. def save_model(model, filename):
  6. converter = tf.lite.TFLiteConverter.from_keras_model(model)
  7. tflite_model = converter.convert()
  8. tflite_models_dir = pathlib.Path("./")
  9. tflite_model_file = tflite_models_dir/filename
  10. tflite_model_file.write_bytes(tflite_model)