Android studio 如何将元数据添加到从tensorflow文件转换而来的tensorflow lite文件中

Android studio 如何将元数据添加到从tensorflow文件转换而来的tensorflow lite文件中,android-studio,tensorflow,tensorflow-lite,Android Studio,Tensorflow,Tensorflow Lite,我正试图将tensorflow lite文件添加到Android studio中,但当我添加它时,我收到一个错误消息,称找不到元数据。我让tensorflow模型在我的笔记本电脑上远程工作,精度达到70%。我使用以下代码将tensorflow转换为tensorflow lite import tensorflow as tf model = tf.keras.models.Sequential([ tf.keras.layers.Dense(units=1, input_shape=[

我正试图将tensorflow lite文件添加到Android studio中,但当我添加它时,我收到一个错误消息,称找不到元数据。我让tensorflow模型在我的笔记本电脑上远程工作,精度达到70%。我使用以下代码将tensorflow转换为tensorflow lite

import tensorflow as tf

model = tf.keras.models.Sequential([
    tf.keras.layers.Dense(units=1, input_shape=[1]),
    tf.keras.layers.Dense(units=16, activation='relu'),
    tf.keras.layers.Dense(units=1)
])
model.compile(optimizer='sgd', loss='mean_squared_error') # compile the model
model.fit(x=[-1, 0, 1], y=[-3, -1, 1], epochs=5) # train the model

converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()


with open('model.tflite', 'wb') as f:
  f.write(tflite_model)
Android Studio上的错误消息-“未找到元数据” 它提供了下面的链接来添加元数据。我无法让脚本正常工作


有谁能解释一下,我将如何调整这个脚本,以适应我的模型,请或任何替代解决方案?我花了数周时间寻找一个解决方案,但没有找到任何解决方案,如有任何帮助,将不胜感激。

当需要使用tflite支持库时,需要元数据。由于您已经拥有转换后的tflite模型,因此可以直接使用tflite解释器API来运行转换后的模型。请参阅tflite android页面

嗨,在,谢谢你的回复。我只是查看了您提供的链接,并添加了tflite文件,如链接中所示,我得到的错误是没有元数据。我应该提到tensorflow模型是用python训练的,所以我不确定如何调用API?我只能看到C代码的一个示例,任何建议都会非常有用“未显示元数据”的消息不是错误。它只是说它没有元数据。当您不依赖TFLite支持库时,可以忽略它。android有一个JavaAPI:Hi-Jae,感谢您的回复。我不确定是否需要TFLite支持库?我正在实现一个犬种识别功能,该功能从用户的摄像机卷中获取一张图像,并将其添加到firebase中,然后应用程序将在此图像上运行tflite文件并给出结果。这是我第一次使用神经网络,所以我非常感谢您对如何实现它提出的任何建议。谢谢请参考以下链接:嗨,在,谢谢你的建议。我已经在笔记本电脑上对TensorFlow模型进行了训练和测试,精度达到70%,因此第一个链接没有提供任何进一步的指导。在第二个环节中,我发现很难将其适应我自己的模型。我根本不使用相机,用户从他们的图库上传,还有很多空白方法,我不知道如何实现。你能解释一下我如何判断我的模型是否需要元数据吗?我不确定TFLite支持库的用途