簡體   English   中英

是否可以在 Android 上運行 ssd_mobilenet_v1_fpn 進行推理?

[英]Is it possible to run ssd_mobilenet_v1_fpn on Android for inference?

我正在為 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 --default0max_default_ranges

我也試過 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 以外的模型?

首先,在應用量化時,性能越來越差。 量化越多(浮動 => 到 int)它變得越差。 對於檢測模型,結果往往不能很好地對小物體進行操作,也不能很好地擬合大物體的邊界框。 我正在寫一篇論文來解決這個問題。 可能很快就會回來告訴你如何用ssd解決它。

其次,我無權查看您的模型,伙計。 但是,根據這個和我的經驗量化,您可以轉換為任何帶有 ssd 主干的檢測模型。 您可能需要按照我給您的說明來確保量化正常

如果輸入是圖像,您應該更改--default_ranges_max=255並使用tflite_convert 順便說一句,你為什么不能為此使用python API? 如果輸入是凍結圖,則可以按如下方式進行轉換:

converter = tf.lite.TFLiteConverter.from_frozen_graph('tmp.pb', input_arrays=..., output_arrays=...)
tflite_model = converter.convert()

同時,對象檢測 API 包含在移動設備上運行 TF2 檢測 API 模型的文檔。 它還包含 python 腳本export_tflite_graph_tf2.py

我找不到在 Android 上運行這個模型的方法,這可能是不可能的,或者我的手機不夠強大。

但是我通過使用兩個不同的網絡解決了我的問題,MobilenetV1 用於對象檢測(僅檢測一類“對象”),一個用於分類(獲取對象的邊界框並對它們進行分類)。 這不是最優雅的解決方案,但至少它有效。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM