Opencv dnn example on Windows doesn't import caffe model properly

asked 2016-12-29 16:40:40 -0500

sahar gravatar image


I have installed Opencv3.2.0 on Windows 7 (64 bits) with dnn module using MS Visual Studio 2013 and CMake 3.7.0 as 32 bit libraries (which is needed by the main program I'm going to use dnn in). Running the sample from tutorial seems to read in the prototxt and binary caffemodel in, adds the blob in with no issue, however, net.foward() crashes. I narrowed down the issue with the net.

if (net.empty())

is false, however

std::vector<cv::string> layernames = net.getLayerNames();

produces a vector of size 1 (instead of size 142, which is the number of layers in the bvlc_googlenet.prototxt)

I tried this all on Ubuntu 16.04 and layernames has 142 memebrs and it runs fine and produce space shuttle with 99.98% probability on that OS.

Does anyone know what the issue is on Windows and how to solve it? I also checked and caffe.pb.h files generated by protobuf-3.1.0 (build through opencv installation) in both Windows and Ubuntu and they are the same.

Thank you

edit retag flag offensive close merge delete


UPDATE: So I was able to run the example. The solution was to use Debug Opencv libraries when I'm running the code in Debug mode, and Release Opencv libraries when I'm running the example in Release mode! However, I am getting different probability output in Debug vs Release mode. This causes trouble when I'm trying to run my own trainedmodel. Do you know if this is a known bug or if there is a solution for this?

sahar gravatar imagesahar ( 2016-12-30 15:21:50 -0500 )edit