比如我的模型在"/tmp/test_saved_model",最后生成文件就在桌面上
import tensorflow as tf
#把pb文件路径改成自己的pb文件路径即可
saved_model_dir="/tmp/test_saved_model"
# Convert the model
converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir) # path to the SavedModel directory
tflite_model = converter.convert()
# Save the model.
with open('model.tflite', 'wb') as f:
f.write(tflite_model)