如何将 TensorFlow JSON 图形模型转换为 .tflite



我正在将这个TensorFlow JS教程移植到Android上。我必须将这个JSON图TensorFlow模型转换为.tflite,以便我可以在那里使用它。

我在谷歌上搜索了TensorFlow模型转换工具,但找不到任何东西。我还查看了Android TensorFlow-lite库是否有办法导入这些图形模型,但我也没有任何发现。

我尝试使用我在这里找到的以下 Python 脚本转换它,但它需要一个 .pb 文件:

import tensorflow as tf
converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir)
tflite_model = converter.convert()
open("converted_model.tflite", "wb").write(tflite_model)

TFLite 转换器目前不支持加载 tf-js 模型。但是,您可以尝试使用tflite自己的posenet模型(https://www.tensorflow.org/lite/models/pose_estimation/overview(

希望这能让事情变得更容易。

最新更新