Skip to content

DNN: Object detection sample: Fix bug with other size#13608

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
allnes:dnn_rework
Jan 25, 2019
Merged

DNN: Object detection sample: Fix bug with other size#13608
opencv-pushbot merged 1 commit intoopencv:3.4from
allnes:dnn_rework

Conversation

@allnes
Copy link
Copy Markdown
Member

@allnes allnes commented Jan 10, 2019

force_builders=Custom

docker_image:Custom=ubuntu-openvino-2018r5:16.04
test_opencl:Custom=ON
buildworker:Custom=linux-2

test_modules=dnn
test_bigdata:Custom=1
tests_filter=*
build_parallel_tests=1

WIP

itr->second[2] = inpBlobs[itr->first]->dims()[1];
itr->second[3] = inpBlobs[itr->first]->dims()[0];
}
netOwner.reshape(inShapes);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

netOwner can be uninitialized in case of networks which are built in runtime (aren't loaded from .xml and .bin but from origin frameworks format). Please check hasNetOwner flag.

CV_Error(Error::StsAssert, "BlobMap key not exist in Blob");
}
itr->second[2] = inpBlobs[itr->first]->dims()[1];
itr->second[3] = inpBlobs[itr->first]->dims()[0];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to replace all the dimensions. Please note that they should be reversed.

@dkurt
Copy link
Copy Markdown
Member

dkurt commented Jan 10, 2019

@allnes, thank you! It'd be nice to add some test for it. Please take a look on

TEST_P(Test_DLDT_two_inputs, as_IR)

as an example. You can use the same model but vary input sizes.

itr->second[2] = inpBlobs[itr->first]->dims()[1];
itr->second[3] = inpBlobs[itr->first]->dims()[0];
}
netOwner.reshape(inShapes);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can also check at first if we really need to call this procedure. I mean if network's shape are matched with input ones there is no need to use it.

if (!std::equal((itr->second).begin(), (itr->second).end(), blobDims.begin()))
{
itr->second = blobDims;
std::reverse(blobDims.begin(), blobDims.end());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need to reverse it here? It looks like blobDims is not used after.

{
std::vector<size_t> dims = output->dims;
std::vector<int> shape(dims.rbegin(), dims.rend());
outputs.assign(1, shape);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove output member completely and extract output shapes from CNNNetwork (calling reshape if needed).

@allnes allnes force-pushed the dnn_rework branch 3 times, most recently from 5ebce7d to b6bb045 Compare January 21, 2019 13:42
@allnes
Copy link
Copy Markdown
Member Author

allnes commented Jan 21, 2019

@dkurt please review me

result_out.push_back(shape);
}
outputs.assign(result_out.begin(), result_out.end());
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outputs should contain a single output shape. We need to find it in curr_t_net.getOutputsInfo() by layer's name (check name Layer's member).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where I get correctly layer's name?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's one of Layer class properties.

equal_flag = false;
}
}
if (!equal_flag) { cnn.reshape(inShapes); }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check if this code is reachable.

@allnes allnes force-pushed the dnn_rework branch 4 times, most recently from 597b3c3 to 97c3bcb Compare January 24, 2019 10:51
Copy link
Copy Markdown
Member

@dkurt dkurt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests passed (excluding "failed to find" Myriad device, which I tested locally).

@opencv-pushbot opencv-pushbot merged commit 97c3bcb into opencv:3.4 Jan 25, 2019
@alalek alalek mentioned this pull request Feb 1, 2019
@allnes allnes deleted the dnn_rework branch February 1, 2019 11:42
@dkurt dkurt mentioned this pull request Nov 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants