Caffe (FlowNet 2.0) and wrong number of inputs

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

platzi gravatar image

Hello,

im using OpenCVSharp (C#) and im trying to use the pretrained FlowNet 2.0 model to estimate the OpticalFlow between two images. https://github.com/lmb-freiburg/flownet2

Using https://github.com/shimat/opencvsharp... in version 4.2.0.202001 (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",
    @"Resources\FlowNet2_weights.caffemodel.h5"))
{
    net.SetPreferableBackend(Net.Backend.OPENCV);
    net.SetPreferableTarget(Net.Target.CPU);

    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

Comments

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 -0600 )edit
1

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 -0600 )edit