System information (version)
OpenCV => 4.5
Operating System / Platform => Windows 64 Bit
Compiler => Visual Studio 2019
Detailed description
I have an ONNX model that was initially trained with pytorch.
I have converted the model to ONNX.
When I try to run forward in opencv python everything looks fine and the dimension of the output is (1, 3, 12, 18, 6) but when I try to run the forward method in opencv c++, the output dimension is {FLOAT32, 1 x -1 x -1}.
I will be glad if you help me.
Steps to reproduce
c++ code:
int inpWidth = 576;
int inpHeight = 384;
Net net = readNetFromONNX(cv::String("f:\\yolov3\\testoutput\\last1.onnx"));;
cv::Mat _image = cv::imread("C:\\Users\\sahand\\Desktop\\yoloconf\\out\\val_00034.jpg");
Mat frame, blob;
_image.copyTo(frame);
blobFromImage(frame, blob, 1 / 255.0, cvSize(inpWidth, inpHeight), Scalar(0, 0, 0), true, false);
net.setInput(blob);
vector<vector<Mat>> out;
net.forward(out, {"126"});
python code:
dim = (576,384)
model_path = "f:\\yolov3\\testoutput\\last1.onnx"
inp = cv.imread("C:\\Users\\sahand\\Desktop\\yoloconf\\out\\val_00034.jpg")
model = cv.dnn.readNetFromONNX(model_path)
model.setInput(cv.dnn.blobFromImage(inp, 1/255, dim, [0,0,0], 1, crop=False))
out = model.forward("126")