I get the following error while loading onnx model (downloaded from here) in OpenCV-C++ (4.6.0-dev) using the given code. What am I doing wrong? Please help me to solve this problem.
[ERROR:0@0.003] global /home/opencv_build/opencv/modules/dnn/src/onnx/onnx_importer.cpp (2564) parseShape DNN/ONNX(Shape): dynamic 'zero' shapes are not supported, input 243 [ 0 0 0 51 ] [ERROR:0@0.003] global /home/opencv_build/opencv/modules/dnn/src/onnx/onnx_importer.cpp (1042) handleNode DNN/ONNX: ERROR during processing node with 1 inputs and 1 outputs: [Shape]:(onnx_node!Shape_70) from domain='ai.onnx' terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.6.0-dev) /home/opencv_build/opencv/modules/dnn/src/onnx/onnx_importer.cpp:1064: error: (-2:Unspecified error) in function 'handleNode'Node [Shape@ai.onnx]:(onnx_node!Shape_70) parse error: OpenCV(4.6.0-dev) /home/opencv_build/opencv/modules/dnn/src/onnx/onnx_importer.cpp:2565: error: (-215:Assertion failed) !isDynamicShape in function 'parseShape'
Aborted (core dumped)
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/dnn/dnn.hpp>
using namespace std;
using namespace cv;
using namespace dnn;
int main()
{
// load the neural network model
cv::dnn::Net net = cv::dnn::readNetFromONNX("yunet.onnx");
}
I can successfully load the model in Python using both of the following two methods: Method 1:
import onnx
onnx_model = onnx.load('yunet.onnx')
onnx.checker.check_model(onnx_model)
Method 2:
#net = cv2.dnn.readNet('yunet.onnx')
net = cv2.dnn.readNetFromONNX('yunet.onnx')
Am I missing something during building the OpenCV from source?