diff --git a/modules/dnn/src/net_impl.cpp b/modules/dnn/src/net_impl.cpp index ba9d6bc36b..a88fb66361 100644 --- a/modules/dnn/src/net_impl.cpp +++ b/modules/dnn/src/net_impl.cpp @@ -1196,7 +1196,18 @@ void Net::Impl::forward(std::vector>& outputBlobs, FPDenormalsIgnoreHintScope fp_denormals_ignore_scope; if (mainGraph) - CV_Error(Error::StsNotImplemented, "The new dnn engine doesn't support inference until a specified layer. If you want to run the whole model, please don't set the outputName argument in the forward() call. If you want to run the model until a specified layer, please use the old dnn engine"); + { + // In the new engine every requested name maps to a single graph output tensor, + // so each nested list holds exactly one blob. + std::vector names(outBlobNames.begin(), outBlobNames.end()); + std::vector flat; + forwardWithMultipleOutputs(flat, names); + CV_Assert(flat.size() == outBlobNames.size()); + outputBlobs.resize(outBlobNames.size()); + for (size_t i = 0; i < outBlobNames.size(); i++) + outputBlobs[i].assign(1, flat[i]); + return; + } std::vector pins; for (int i = 0; i < outBlobNames.size(); i++)