如何将 .py 文件内带有图像检测模式的 .py 文件转换为 tflite 文件,以便在 android studio 中作为应用程序实现
import tensorflow as tf
# Convert the model
converter = tf.lite.TFLiteConverter.from_saved_model("Modal.py")
tflite_model = converter.convert()
# Save the model.
with open('fruits_model.tflite', 'wb') as f:
f.write(tflite_model)
通常您无法直接从脚本/py 文件进行转换,您是否在寻找 .pt 文件? Google 有一个用于转换 PyTorch 模型的新库:https://github.com/google-ai-edge/ai-edge-torch