-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Error when calling net.forward() in C++ #18392
Copy link
Copy link
Closed
Labels
Milestone
Description
System information (version)
- OpenCV => 4.4.0
- Operating System / Platform => Windows 10 64 Bit
- Compiler => Visual Studio 2017
Detailed description
The code below properly load model, but when calling forward method Assertion error is thrown. Python version of the code works, the CPP doesn't.
Tensorflow model: https://drive.google.com/file/d/1aE0smAw-CyPLch6UY8blK3RreT5RrZfN/view?usp=sharing
Steps to reproduce
cv::dnn::Net net;
string path;
path = "graph.pb";
net = cv::dnn::readNetFromTensorflow(path);
if (net.empty())
{
std::cerr << "Can't load network by using the given files." << std::endl;
return ;
}
Mat image = imread(imagePath)
Mat inputBlob = cv::dnn::blobFromImage(image, 1.0, Size(512, 512), Scalar(0,0,0), true, false);
int N = inputBlob.size[0], C = inputBlob.size[1], H = inputBlob.size[2], W = inputBlob.size[3]; // [1, 3, 512, 512]
net.setInput(inputBlob); //set the network input
Mat output = net.forward(); // <- throws error
Error
Debug Assertion Failed!
Program: C:\Workspace\ImageAnalysisPlus\x64\Debug\opencv_world3410d.dll File: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector Line: 1789
Expression: back() called on empty vector
For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.
Issue submission checklist
- [✓] I report the issue, it's not a question
- [✓] I checked the problem with documentation, FAQ, open issues,
answers.opencv.org, Stack Overflow, etc and have not found solution - [✓] I updated to latest OpenCV version and the issue is still there
- [✓] There is reproducer code and related data files: videos, images, onnx, etc - model attached, code "works" with any image
Details
Reactions are currently unavailable
