1 回答
TA贡献1752条经验 获得超4个赞
你可以尝试像下面这样的东西TF2.2。
import tensorflow as tf
graph_def_file = "./saved_model.pb"
tflite_file = 'mytflite.tflite'
input_arrays = ["input"]. # you need to change it based on your model
output_arrays = ["output"] # you need to change it based on your model
print("{} -> {}".format(graph_def_file, tflite_file))
converter = tf.compat.v1.lite.TFLiteConverter.from_frozen_graph(
graph_def_file=graph_def_file,
input_arrays=input_arrays,
output_arrays=output_arrays,input_shapes={'input_mel':[ 1, 50, 80]})
# If there are multiple inputs, then update the dictionary above
tflite_model = converter.convert()
open(tflite_file,'wb').write(tflite_model)
在上面的代码中,您需要使用与您的模型相对应的input_arrays, output_arrays, 和。input_shapes
添加回答
举报