簡體   English   中英

TensorFlow Lite Object 檢測 iOS 不適用於經過自定義訓練的 Z20F35E630DAF44DBFA4C3F68FZ53

[英]TensorFlow Lite Object Detection iOS does not work with custom trained model

我已經訓練了我的ssd_mobilenet_v2_quantized_300x300_coco_2019_01_03 object 檢測 model。 一切順利。 我還將其轉換為 .tflite 文件並將其命名為detectx.tflite

我下載了官方的 ObjectDetection 示例應用程序,它與 inlcuded.tflite model 一起運行順利。

我將ModelDataHandler.swift中的代碼更改為以下代碼:

enum MobileNetSSD {
  static let modelInfo: FileInfo = (name: "detectx", extension: "tflite")
  static let labelsInfo: FileInfo = (name: "labelmap", extension: "txt")
}

並且肯定將我的detectx.tflite 移動到Model文件夾中,以便可以找到它。

但是,當我嘗試運行該應用程序時,它崩潰並出現以下錯誤:

Failed to load the model file with name: detectx (lldb)

這就是我將訓練有素的 model 導出到tflite_graph.pb的方式:

python export_tflite_ssd_graph.py \
    --pipeline_config_path training/ssd_mobilenet_v2_quantized_300x300_coco.config \
    --trained_checkpoint_prefix training/model.ckpt-145 \
    --output_directory inference_graph_TFLITE_COBA

這就是我將其轉換為 .tflite 的方式:

tflite_convert --graph_def_file=inference_graph_TFLITE_COBA/tflite_graph.pb --output_file=detectx.tflite 
--input_shapes=1,300,300,3 --input_arrays=normalized_input_image_tensor 
--output_arrays=TFLite_Detection_PostProcess,TFLite_Detection_PostProcess:1,TFLite_Detection_Post
Process:2,TFLite_Detection_PostProcess:3 --allow_custom_ops

正如我在那里寫的那樣,這成功地產生了detectx.tflite

我不明白為什么這不起作用。 我嘗試了許多不同的 ssd 移動網絡模型,也產生了同樣的錯誤。 有人可以幫我嗎? 我超級困惑。

非常感謝。 我真的很感激任何幫助。

我也遇到了同樣的錯誤消息Failed to load the model file with name: detectx (lldb) from Xcode 在您使用的示例項目中。

在對 Xcode 進行調試后,我意識到 model 根本沒有加載到項目文件中,我可以通過在 ZA3B5EBD8A1E9EBF44A17ZE80D5A7D3A 上按照以下步驟解決問題:

  1. 點擊您的項目
  2. 點擊你的目標
  3. Select 構建階段
  4. 展開復制捆綁資源
  5. 單擊“+”和 select 您的 model 文件

將文件拖入 Xcode 項目時,請確保檢查應用程序目標以確保在“構建階段”選項卡的“復制捆綁資源”部分中設置了對該文件的引用。

暫無
暫無

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

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