net.forward() gives Assertion failed (m.dims > 2) in getPlane

asked 2017-12-19 00:19:04 -0500

kiran734 gravatar image

I am training and saving a model in tensorflow and load the saved model in opencv 3.3. After setting the input and trying net.forward(), the following error occurs: OpenCV Error: Assertion failed (m.dims > 2) in getPlane, file /home/kiran/new_opencv/opencv-master/modules/dnn/include/opencv2/dnn/shape_utils.hpp, line 114 terminate called after throwing an instance of 'cv::Exception' what(): /home/kiran/new_opencv/opencv-master/modules/dnn/include/opencv2/dnn/shape_utils.hpp:114: error: (-215) m.dims > 2 in function getPlane

The code is:

Mat img = imread(image);
Mat resampled_image(Size(48,48),CV_8UC3,Scalar::all(0));        
resize(img, resampled_image,Size(48,48), 0, 0,INTER_AREA);
Net net = readNetFromTensorflow(modelFile);
Mat inputBlob = blobFromImage(resampled_image,1.0f,Size(48,48),Scalar(),true,false);
net.setInput(inputBlob, input_layer);
Mat result2 = net.forward();
edit retag flag offensive close merge delete