Caffe (FlowNet 2.0) and wrong number of inputs

asked 2020-01-08 08:46:31 -0500

platzi gravatar image


im using OpenCVSharp (C#) and im trying to use the pretrained FlowNet 2.0 model to estimate the OpticalFlow between two images.

Using in version (Released 08.01.2020)

For FlowNet 2.0 the models can be downloaded through an shell script. They contains different version of the model with different feature sets. They contain an "weights.caffemodel" and two "prototxt" templates. One for training and one for deployment. In the Deployment-Template i have replaced some placeholder to real resolutions.

I'm loading the model and sets my 2 inputs. But if i'm calling Forward i always get the exception "inputs.size() >= 2".

using (var net = CvDnn.ReadNetFromCaffe(@"Resources\FlowNet2_deploy.prototxt.template",

    var img0 = CvDnn.BlobFromImage(left, 1.0, new Size(1024, 720), new Scalar(), true, false);
    var img1 = CvDnn.BlobFromImage(right, 1.0, new Size(1024, 720), new Scalar(), true, false);
    net.SetInput(img0, "img0");
    net.SetInput(img1, "img1");

    var predict = net.Forward("predict_flow_final");  << exception

Has anyone an idea what this can be? Maybe OpenCV is not compatible to this CNN?

edit retag flag offensive close merge delete


i don't think, opencv's dnn supports more than 1 input (and calling setInput() twice just overwrites the first)

berak gravatar imageberak ( 2020-01-10 01:41:34 -0500 )edit

Yeah. It seems like so. On the official github wiki page they talks about "Multiple inputs/outputs are supported". But nearly all examples uses only a single input. Maybe some of the official developers has to check this with this kind of network. I think.

platzi gravatar imageplatzi ( 2020-01-10 03:10:56 -0500 )edit