Net.forward crash using cv::dnn::blobFromImages

Hi,
I’m using an ONNX classification model and I’m testing inference using opencv 4.12.0. I have no problem using the net over a single image sample:

cv::dnn::blobFromImage( frame, blob, 1.0/255.0, imgSz, cv::Scalar(), true, false );
net.setInput( blob );
net.forward( outs, outputlayers );

but if I try to perform an inference over several samples at a time I got a net.forward() crash:

cv::dnn::blobFromImages( frames, blob, 1.0/255.0, imgSz, cv::Scalar(), true, false );
net.setInput( blob );
net.forward( outs, outputlayers_all );

the crash is the following one:

OpenCV Error: Assertion failed ((int)_numAxes == inputs[0].size()) in 		cv::dnn::PermuteLayerImpl::getMemoryShapes, file D:\Data\opencv\opencv-4.12.0\modules\dnn\src\layers\permute_layer.cpp, line 162

my net model take as input a NCHW image (1, 3, 320, 320). How have I to call net.forward using the multisample input got from blobFromImages, i.e. (4, 3, 320, 320)? I’m trying to improve performace using some kind of parallelism rather than execute each sample in sequence.
thank you, best regards
Andrea

I haven’t used the dnn module myself.

the assertion is here:

if you can debug into the library, I’d suggest you do that.

_numAxes comes from here:

Hi crackwitz,
thank you for the reply. I realised that I need a dnn with an input node that takes (4,3,320,320) data to avoid that crash. What I effectively need is to execute several inference in parallel to optimise detection time. Does net.forward() support multi-threads? I suppose it doesn’t because my application crashes trying to invoke it on the same net from several threads. Any suggestions? Have I to clone the net to use parallelism?

Thank you, best regards
Andrea