Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

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 1348*48

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

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 1348*48 1x3x48x48