首页 > 解决方案 > 是否可以在 Android 上运行 ssd_mobilenet_v1_fpn 进行推理?

问题描述

我正在为 Android 制作一个对象检测应用程序,我在使用 ssd_mobilenet_v1_fpn 模型进行训练时获得了良好的性能。

我导出了冻结推理图,转换为 tflite 并对其进行量化以提高性能。但是当我在TensorFlow Lite Object Detection Android Demo上尝试它时 ,应用程序崩溃了。

该应用程序与默认模型 (ssd_mobilenet_v1) 完美配合,但不幸的是不适合小物体检测和分类。

这是我的量化 ssd_mobilenet_v1_fpn 模型

谷歌云端硬盘:https ://drive.google.com/file/d/1rfc64nUJzHQjxigD6hZ6FqxyGhLRbyB1/view?usp=sharing

OneDrive:https ://univpr-my.sharepoint.com/:u:/g/personal/vito_filomeno_studenti_unipr_it/EXtl9aitsUZBg6w3awcLbfcBGBgrSV4kqBdSlS3LJOXKkg?e=kHEcy2

这里是未量化的模型

谷歌驱动器:https ://drive.google.com/file/d/11c_PdgobP0jvzTnssOkmcjp19DZoBAAQ/view?usp=sharing

OneDrive:https ://univpr-my.sharepoint.com/:u:/g/personal/vito_filomeno_studenti_unipr_it/EcVpJ44Daf5OgpVTYG1eD38B6P1mbnospRb8wXU_WQRh0g?e=cIgpQ2

对于量化,我使用了这个命令行:

bazel run -c opt tensorflow/lite/toco:toco -- \ --input_file=tflite_graph.pb \ --output_file=detect_quant.tflite \ --input_shapes=1,640,480,3 \ --input_arrays=normalized_input_image_tensor \ --output_arrays=TFLite_Detection_PostProcess ,TFLite_Detection_PostProcess:1,TFLite_Detection_PostProcess:2,TFLite_Detection_PostProcess:3 \ --inference_type=QUANTIZED_UINT8 \ --mean_values=128 \ --std_values=128 \ --change_concat_input_ranges=false \ --allow_custom_ops --default_ranges_min=0 --default_ranges_max=6

我也尝试了 tflite 转换器 python api,但它不适用于这个模型。

这里是android logcat错误错误

2020-09-16 18:54:06.363 29747-29747/org.tensorflow.lite.examples.detection E/Minikin:无法获取 cmap 表大小!

2020-09-16 18:54:06.364 29747-29767/org.tensorflow.lite.examples.detection E/MemoryLeakMonitorManager:MemoryLeakMonitor.jar 不存在!

2020-09-16 18:54:06.871 29747-29747/org.tensorflow.lite.examples.detection E/BufferQueueProducer: [] 无法获得 hwsched 服务

2020-09-16 18:54:21.033 29747-29786/org.tensorflow.lite.examples.detection A/libc:致命信号 6 (SIGABRT),tid 29786 中的代码 -6(推理)

有没有人设法在android上使用fpn模型?还是 ssd_mobilenet_v1 以外的模型?

标签: androidtensorflowtensorflow-liteobject-detection-apimobilenet

解决方案


首先,当应用量化时,性能越来越差。量化越多(浮点 => 到 int)它变得越差。对于检测模型,结果往往不能很好地对小物体进行操作,并且不能很好地拟合大物体的边界框。我正在写一篇论文来解决这个问题。可能会尽快回复您如何使用 ssd 解决它。

其次,我无权查看你的模型,伙计。但是,根据这个和我的经验量化,您可以转换为任何具有 ssd 主干的检测模型。您可能需要按照我给您的说明来确保量化正常


推荐阅读