Tensorflow再训练模型在AndroidDevi上表现不同

2024-06-16 13:51:15 发布

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

我用一些自定义图像重新训练了模型,如tensorflow for poets教程中所述。你知道吗

当我用下面的命令在我的计算机上运行模型时 python -m scripts.label_image --graph=tf_files/retrained_graph.pb --image=tf_files/test_photos/apple.jpg

我希望它能分类为苹果,我得到正确的分类结果是:

apple 1.0 orange 1.40016e-08 lemon 2.19029e-09

当我将重新训练的模型和标签文件复制到androidstudio的assets文件夹并构建apk时,即使我向模型提供相同的图像,也会得到不同的分类结果。你知道吗

See the image of the classification result from the app that is built using the same model

我认为问题是由anaconda和android studio的不同tensorflow版本引起的。因此,我将tensorflow版本升级到1.7.0来构建模型,并在androidstudio中实现了tensorflow的依赖关系

compile 'org.tensorflow:tensorflow-android:+' 

我也试过依赖

compile 'org.tensorflow:tensorflow-android:1.7.0'

但我收到了另一个错误,应用程序在启动后立即崩溃,所以我不得不返回

'org.tensorflow:tensorflow-android:+' 

Tags: theorg模型图像imageapplefortf
1条回答
网友
1楼 · 发布于 2024-06-16 13:51:15

最后,即使优化和量化都完成了,我也无法让tensorflow for mobile工作。同样的图像在手机和电脑上输出完全不同的结果。你知道吗

因此,我改为Tensorflow Lite。用tensorflow lite解决了我的问题。一个简短的说明:Tensorflow lite在windows上不受支持(尤其是toco),因此我不得不使用ubuntu。你知道吗

相关问题 更多 >