Ask Your Question

Revision history [back]

How to load a Siamese Net in opencv dnn?

I am trying to deploy a siamese net with opencv. Basically, I understand as a siamese net, a net where I have two inputs, a sequential model and a concatenated output. Critically, both inputs share the same weights. The model looks like this:

in1, in2 => sequential => concatenate & dense

In Keras/Tensorflow this is no problem. I am even able to freeze and load the net in opencv, but when i try the forward pass, I get the following error:

/opencv/modules/dnn/src/dnn.cpp:418: error: (-215:Assertion failed) inputs.size() == requiredOutputs in function 'getMemoryShapes'

assuming my inputs are called L and R, i first set:

net.setInputsNames( std::vector<String>{ "L", "R" } );

and then, net.setInput(inBlobL, "L" ); net.setInput(inBlobR, "R" );

I make sure to resize the input images properly. Does anyone have an idea whether what I am trying to do is possible at all?

Or do I have to find a workaround?