Skip to content

Commit

Permalink
Fix autodetection of input size for dnn networks
Browse files Browse the repository at this point in the history
  • Loading branch information
dkurt committed Sep 30, 2019
1 parent 507ca29 commit fba9fdf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
24 changes: 16 additions & 8 deletions modules/dnn/src/dnn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2506,17 +2506,25 @@ struct Net::Impl
{
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;
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())
{
Expand Down
3 changes: 1 addition & 2 deletions modules/dnn/test/test_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ TEST_P(Test_Model, Classify)
}


// disabled: https://github.com/opencv/opencv/pull/15593
TEST_P(Test_Model, DISABLED_DetectRegion)
TEST_P(Test_Model, DetectRegion)
{
applyTestTag(CV_TEST_TAG_LONG, CV_TEST_TAG_MEMORY_1GB);

Expand Down

0 comments on commit fba9fdf

Please sign in to comment.