YOLO5 doesn't work in OpenCV v4.5.1

Hello;
I want to use a yolo5 model under c++ for the prediction part, for that I use dnn with an onnx extension model, but I get the following error :

[ERROR:0] global /home/nvidia/workspace4/opencv_4.5_build/opencv-master/modules/dnn/src/onnx/onnx_importer.cpp (1878) handleNode DNN/ONNX: ERROR during processing node with 1 inputs and 1 outputs: [Identity]:(onnx::Resize_445)
terminate called after throwing an instance of ‘cv::Exception’
what(): OpenCV(4.5.1-dev) /home/nvidia/workspace4/opencv_4.5_build/opencv-master/modules/dnn/src/onnx/onnx_importer.cpp:1887: error: (-2:Unspecified error) in function ‘handleNode’

Node [Identity]:(onnx::Resize_445) parse error: OpenCV(4.5.1-dev) /home/nvidia/workspace4/opencv_4.5_build/opencv-master/modules/dnn/src/dnn.cpp:5284: error: (-215:Assertion failed) inputs.size() in function ‘getMemoryShapes’

Aborted (core dumped)

I use Ubuntu 18.04 , OpenCV 4.5 , Cuda 10.2 , c++
Thank you in advance for your answer.

most likely a 404 problem, see:

check the path to it, the onnx file is not, where your program expects it …

Hello;
I want to use a yolo5 model under c++ for the prediction part, for that I use dnn with an onnx extension model, but I get the following error :

[ERROR:0] global /home/nvidia/workspace4/opencv_4.5_build/opencv-master/modules/dnn/src/onnx/onnx_importer.cpp (1878) handleNode DNN/ONNX: ERROR during processing node with 1 inputs and 1 outputs: [Identity]:(onnx::Resize_445)
terminate called after throwing an instance of ‘cv::Exception’
what(): OpenCV(4.5.1-dev) /home/nvidia/workspace4/opencv_4.5_build/opencv-master/modules/dnn/src/onnx/onnx_importer.cpp:1887: error: (-2:Unspecified error) in function ‘handleNode’

Node [Identity]:(onnx::Resize_445) parse error: OpenCV(4.5.1-dev) /home/nvidia/workspace4/opencv_4.5_build/opencv-master/modules/dnn/src/dnn.cpp:5284: error: (-215:Assertion failed) inputs.size() in function ‘getMemoryShapes’

Aborted (core dumped)

I use Ubuntu 18.04 , OpenCV 4.5 , Cuda 10.2 , c++
Thank you in advance for your answer.

well it DOES work with current 4.7.0, so please update from 4.5.1

also, since they recently also added yolov5 classification / segmentation models there, – what exactly are you trying with ?

1 Like

please do not open multiple threads for the same thing. I merged those two threads.

thank you for your answer, in my case I do segmentation for a specific dataset, I had done the training with python of yolov5 but by technical necessity I was obliged to pass to c++ and thus I will use only the prediction part.