Fix autodetection of input size for dnn networks

This commit is contained in:
Dmitry Kurtaev 2019-09-29 22:02:42 +03:00
parent 507ca291e1
commit fba9fdfd27
2 changed files with 17 additions and 10 deletions

View File

@ -2506,17 +2506,25 @@ struct Net::Impl
{ {
std::vector<LayerPin>& inputLayerIds = layers[id].inputBlobsId; std::vector<LayerPin>& inputLayerIds = layers[id].inputBlobsId;
if (inOutShapes[0].in[0].empty() && !layers[0].outputBlobs.empty()) if (id == 0 && inOutShapes[id].in[0].empty())
{ {
ShapesVec shapes; if (!layers[0].outputBlobs.empty())
for (int i = 0; i < layers[0].outputBlobs.size(); i++)
{ {
Mat& inp = layers[0].outputBlobs[i]; ShapesVec shapes;
CV_Assert(inp.total()); for (int i = 0; i < layers[0].outputBlobs.size(); i++)
shapes.push_back(shape(inp)); {
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()) if (inOutShapes[id].in.empty())
{ {

View File

@ -105,8 +105,7 @@ TEST_P(Test_Model, Classify)
} }
// disabled: https://github.com/opencv/opencv/pull/15593 TEST_P(Test_Model, DetectRegion)
TEST_P(Test_Model, DISABLED_DetectRegion)
{ {
applyTestTag(CV_TEST_TAG_LONG, CV_TEST_TAG_MEMORY_1GB); applyTestTag(CV_TEST_TAG_LONG, CV_TEST_TAG_MEMORY_1GB);