我已经训练了我的ssd_mobilenet_v2_quantized_300x300_coco_2019_01_03对象检测模型。一切顺利。我还将它转换为 .tflite 文件并将其命名为detectx.tflite。
我下载了官方的 ObjectDetection 示例应用程序,它使用包含的 .tflite 模型运行顺畅。
我将代码更改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)
这就是我将训练好的模型导出到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 移动网络模型,也产生了同样的错误。有人可以帮我吗?我超级困惑。
非常感谢。我真的很感激任何帮助。