如何将.pb文件转换为.tflite。在tensorflow 2.1.0中

2024-05-16 12:30:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经使用SSD MobileNet V2 FPNLite 640x640和tensorflow 2.1.0对我的模型进行了培训。要创建.pb文件,请使用文件导出\u tflite\u图形\u tf2.py。现在,希望将.pb文件转换为.tflite。 我使用了tensorflow社区推荐的以下代码。但它正在将模型转换为1kb tflite文件

我也试着每晚使用tf,但同样的转换成1kb

import tensorflow as tf

# 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)

Tags: 文件the模型modeltftensorflowasconverter