Android中的Tensorflow对象检测性能下降

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进行本地测试并且结果差很多,那么转换就出问题了。通常,训练后量化不会大幅度降低模型的准确性,在最坏的情况下只会降低2-3%。

如果在向本地Python解释器馈送图像时结果不错(即,当您在本地测试转换后的tf-lite模型时),则表明馈送输入数据的方式存在问题在Android上。将数据馈送到移动应用程序上的图像时,请确保使用完全相同的预处理步骤,例如训练期间的步骤。