环境 win11 yolov5 v6.0 opencv450
通过谷歌colab训练结果为last.pt
https://download.csdn.net/download/qq_43799658/85044175
在终端中使用
python export.py --weights './last.pt'
转换后是这样
yolo.h
文件修改为
main.cpp文件修改为
运行程序出错,在VS的调试控制台出现
[ INFO:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\onnx\onnx_importer.cpp (392) cv::dnn::dnn4_v20200908::ONNXImporter::populateNet DNN/ONNX: loading ONNX v7 model produced by 'pytorch':1.10. Number of nodes = 351, inputs = 1, outputs = 4
OpenCV(4.5.0) Error: Unspecified error (> Slice layer only supports steps = 1 (expected: 'countNonZero(step_blob != 1) == 0'), where
> 'countNonZero(step_blob != 1)' is 1
> must be equal to
> '0' is 0
) in void __cdecl cv::dnn::dnn4_v20200908::ONNXImporter::handleNode(const class opencv_onnx::NodeProto &), file C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\onnx\onnx_importer.cpp, line 697
[ERROR:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\onnx\onnx_importer.cpp (1788) cv::dnn::dnn4_v20200908::ONNXImporter::handleNode DNN/ONNX: ERROR during processing node with 5 inputs and 1 outputs: [Slice]:(130)
[ INFO:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\onnx\onnx_importer.cpp (1791) cv::dnn::dnn4_v20200908::ONNXImporter::handleNode Input[0] = 'images'
[ INFO:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\onnx\onnx_importer.cpp (1791) cv::dnn::dnn4_v20200908::ONNXImporter::handleNode Input[1] = '127'
[ INFO:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\onnx\onnx_importer.cpp (1791) cv::dnn::dnn4_v20200908::ONNXImporter::handleNode Input[2] = '128'
[ INFO:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\onnx\onnx_importer.cpp (1791) cv::dnn::dnn4_v20200908::ONNXImporter::handleNode Input[3] = '126'
[ INFO:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\onnx\onnx_importer.cpp (1791) cv::dnn::dnn4_v20200908::ONNXImporter::handleNode Input[4] = '129'
[ INFO:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\onnx\onnx_importer.cpp (1795) cv::dnn::dnn4_v20200908::ONNXImporter::handleNode Output[0] = '130'
OpenCV(4.5.0) Error: Unspecified error (> Node [Slice]:(130) parse error: OpenCV(4.5.0) C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\onnx\onnx_importer.cpp:697: error: (-2:Unspecified error) in function 'void __cdecl cv::dnn::dnn4_v20200908::ONNXImporter::handleNode(const class opencv_onnx::NodeProto &)'
> > Slice layer only supports steps = 1 (expected: 'countNonZero(step_blob != 1) == 0'), where
> > 'countNonZero(step_blob != 1)' is 1
> > must be equal to
> > '0' is 0
> ) in cv::dnn::dnn4_v20200908::ONNXImporter::handleNode, file C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\onnx\onnx_importer.cpp, line 1797
因为刚接触机器视觉、图像处理及C++的知识,希望能明示问题所在,也恳求能教我如何解决。万分感谢!