opencv: net can't forward again?
my envs: openVINO2019.1.148+win10+VS2015 When I use bvlc_googlenet.xml and the bvlc_googlenet.bin model to extract image features, the network model can only successfully forward only one time. When the second time loop, images length is not the same with the first time,it will go wrong. Why,any idea ? thank you!
OpenCV: terminate handler is called! The last OpenCV error is: OpenCV(4.1.0-openvino) Error: Assertion failed (!isInitialized()) in cv::dnn::InfEngineBackendNet::initPlugin, file C:\jenkins\workspace\OpenCV\OpenVINO\build\opencv\modules\dnn\src\op_inf_engine.cpp, line 688
The main code that caused the error is:
Net net = readNetFromModelOptimizer(xmlFile,model);// 此模式下必须设置为DNN_BACKEND_INFERENCE_ENGINE
if (net.empty())
{
cout << "net is empty!" << endl;
}
net.setPreferableBackend(DNN_BACKEND_INFERENCE_ENGINE);
net.setPreferableTarget(DNN_TARGET_CPU);
int net_size = 224;
images.clear();
images.push_back(img);
while (true)
{
Mat blob;
blobFromImages(images, blob, 1.0, Size(net_size, net_size), Scalar(104, 117, 123), false);
net.setInput(blob);
Mat prob = net.forward("pool5/7x7_s1"); // second time, error! (when images length is not the same with the first time)
images.push_back(img); // for example , add image to images
}
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 24 (22 by maintainers)
I have reproduced this. It looks like this is a bug in OpenCV: changing the shape of the input blob causes it to reinitialize the backend, which it fails to do. I am thus going to transfer this issue to the OpenCV repository.
Thanks everyone! Please try this patch: https://github.com/opencv/opencv/pull/17102