DNN: Object detection sample: Fix bug with other size#13608
DNN: Object detection sample: Fix bug with other size#13608opencv-pushbot merged 1 commit intoopencv:3.4from
Conversation
modules/dnn/src/op_inf_engine.cpp
Outdated
| itr->second[2] = inpBlobs[itr->first]->dims()[1]; | ||
| itr->second[3] = inpBlobs[itr->first]->dims()[0]; | ||
| } | ||
| netOwner.reshape(inShapes); |
There was a problem hiding this comment.
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.
modules/dnn/src/op_inf_engine.cpp
Outdated
| 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]; |
There was a problem hiding this comment.
I think it's better to replace all the dimensions. Please note that they should be reversed.
|
@allnes, thank you! It'd be nice to add some test for it. Please take a look on opencv/modules/dnn/test/test_layers.cpp Line 1016 in 7e2ebec as an example. You can use the same model but vary input sizes. |
modules/dnn/src/op_inf_engine.cpp
Outdated
| itr->second[2] = inpBlobs[itr->first]->dims()[1]; | ||
| itr->second[3] = inpBlobs[itr->first]->dims()[0]; | ||
| } | ||
| netOwner.reshape(inShapes); |
There was a problem hiding this comment.
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.
modules/dnn/src/op_inf_engine.cpp
Outdated
| if (!std::equal((itr->second).begin(), (itr->second).end(), blobDims.begin())) | ||
| { | ||
| itr->second = blobDims; | ||
| std::reverse(blobDims.begin(), blobDims.end()); |
There was a problem hiding this comment.
Why we need to reverse it here? It looks like blobDims is not used after.
modules/dnn/src/op_inf_engine.cpp
Outdated
| { | ||
| std::vector<size_t> dims = output->dims; | ||
| std::vector<int> shape(dims.rbegin(), dims.rend()); | ||
| outputs.assign(1, shape); |
There was a problem hiding this comment.
Can we remove output member completely and extract output shapes from CNNNetwork (calling reshape if needed).
5ebce7d to
b6bb045
Compare
|
@dkurt please review me |
| result_out.push_back(shape); | ||
| } | ||
| outputs.assign(result_out.begin(), result_out.end()); | ||
| } |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Where I get correctly layer's name?
There was a problem hiding this comment.
It's one of Layer class properties.
modules/dnn/src/op_inf_engine.cpp
Outdated
| equal_flag = false; | ||
| } | ||
| } | ||
| if (!equal_flag) { cnn.reshape(inShapes); } |
There was a problem hiding this comment.
Please check if this code is reachable.
597b3c3 to
97c3bcb
Compare
dkurt
left a comment
There was a problem hiding this comment.
Tests passed (excluding "failed to find" Myriad device, which I tested locally).
WIP