inpBlob.size[1] == blobs[0].total() error while importing pb file to Opencv

asked 2018-01-08 23:32:30 -0600

kiran734 gravatar image

updated 2018-01-08 23:33:01 -0600

I was trying to import a pb file to OpenCV. Then I encountered the following error: OpenCV Error: Assertion failed (inpBlob.size[1] == blobs[0].total()) in forward, file /home/kiran/new_opencv/opencv-master/modules/dnn/src/layers/scale_layer.cpp, line 65

The corresponding code is:

Net net = readNetFromTensorflow(modelFile);
if (net.empty())
    {
        cout << "Can't load network by using the mode file: " << modelFile <<endl;
        exit(-1);
    }
string input_layer = "onet/input";
Mat resampled_image_test(Size(48,48),CV_8UC3,Scalar::all(0));
Mat inputBlob = blobFromImage(resampled_image_test,1.0f,Size(48,48),Scalar(),true,false);
std::cout << inputBlob.size << std::endl;
net.setInput(inputBlob, input_layer);
auto result = net.forward();

The inputBlolb.size is 1x3x48x48

edit retag flag offensive close merge delete