Tensorflow 对象检测性能下降 Android

Tensorflow Object Detection Performance Drop in Android

我最近使用Tensorflow 1.15训练了一个目标检测模型,使用Python的测试结果很好。然而,在将其转换为 .tflite 格式后,运行 Android 上的模型显示其性能急剧下降。

模型转换为 tf-lite 时是否会出现性能损失? 有没有办法避免转换过程中的这种性能损失?

参考:

培训来源:https://github.com/tensorflow/models/tree/master/research/object_detection

迁移学习的基本模型:ssd_mobilenet_v1

模型转换:https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/running_on_mobile_tensorflowlite.md

Python 测试脚本:https://github.com/tensorflow/models/blob/master/research/object_detection/object_detection_tutorial.ipynb

Android 演示应用程序:https://github.com/tensorflow/examples/tree/master/lite/examples/object_detection

我要做的第一步是用本地 Python 解释器测试它(转换后);这样,如果您在本地使用 Python 进行测试并且结果更差,则转换有问题。通常,post-训练量化不应显着降低模型的准确性,在最坏的情况下只会降低 2-3%。

如果你给本地的 Python Interpreter feed images 的结果还不错,(即你在本地测试你转换后的 tf-lite 模型时),那么说明方法有问题您正在 Android 上提供您的输入数据。确保在为移动应用程序上的图像提供数据时应用完全相同的预处理步骤,就像在训练阶段一样。