From 134094a442f2944ccb3605e2f836f3747295acbc Mon Sep 17 00:00:00 2001 From: Dmitry Kurtaev Date: Thu, 5 Dec 2019 19:25:51 +0300 Subject: [PATCH] Backport fix for autodetection of input shapes --- modules/dnn/src/dnn.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/modules/dnn/src/dnn.cpp b/modules/dnn/src/dnn.cpp index 83b6b9f..cd51282 100644 --- a/modules/dnn/src/dnn.cpp +++ b/modules/dnn/src/dnn.cpp @@ -2772,17 +2772,25 @@ struct Net::Impl { std::vector& inputLayerIds = layers[id].inputBlobsId; - if (inOutShapes[0].in[0].empty() && !layers[0].outputBlobs.empty()) + if (id == 0 && inOutShapes[id].in[0].empty()) { - ShapesVec shapes; - for (int i = 0; i < layers[0].outputBlobs.size(); i++) + if (!layers[0].outputBlobs.empty()) { - Mat& inp = layers[0].outputBlobs[i]; - CV_Assert(inp.total()); - shapes.push_back(shape(inp)); + ShapesVec shapes; + for (int i = 0; i < layers[0].outputBlobs.size(); i++) + { + Mat& inp = layers[0].outputBlobs[i]; + CV_Assert(inp.total()); + shapes.push_back(shape(inp)); + } + inOutShapes[0].in = shapes; } - inOutShapes[0].in = shapes; - } + else + { + inOutShapes[0].out.clear(); + return; + } + } if (inOutShapes[id].in.empty()) { -- 2.7.4