将 yolov5 模型转换为 ONNX 并在 c++ 接口上运行

时间:2021-05-05 04:47:17

标签: onnx yolov5

我将 yolo 模型设为 yolov5s.yaml 并将我的权重文件保存为 best.pt 。 现在想将 yolo 模型转换为 ONNX 并在 c++ 界面上运行。 我已经经历了这个 https://github.com/ultralytics/yolov5/issues/251 但无法做到。任何帮助或有用的资源都会有所帮助。 谢谢

2 个答案:

答案 0 :(得分:0)

我可以成功运行 https://github.com/ultralytics/yolov5/issues/251 中提到的示例。我的火炬版本是 1.8.0。

可能是您的权重文件 best.pt 包含无效值。你有没有尝试过使用上面链接中的权重文件成功导出模块?

顺便说一句:您可以在 https://github.com/microsoft/onnxruntime/tree/master/samples/c_cxx 中找到使用 ONNXRuntime C++ api 来运行它的示例。

答案 1 :(得分:0)

我尝试成功运行第一个链接中提供的示例,语句为: git clone github.com/ultralytics/yolov5 # clone repo cd yolov5 pip install -r requirements.txt # 基本要求 pip install coremltools>=4.1 onnx>=1.9.0 scikit-learn==0.19.2 # 导出要求 python models/export.py --weights yolov5s.pt --img 640 --batch 1 # 以 640x640 批量导出1

显示导出成功。上面例子中的权重文件是 yolov5s.pt。使用 best.pt 文件运行这些语句时,您遇到了哪些错误?

相关问题