Repository navigation
Make use of explicit output shape for the de-convolution layer. - #13989
Conversation
|
@kohei-us, Can you add a test? |
|
@dkurt Sure, I can look into that. Any suggestion as to where to add a new test? |
|
I guess modules/dnn/test/test_onnx_importer.cpp may be a good place for this (?) |
|
@kohei-us, Yeah. |
…layer. This is related to opencv/opencv#13989.
|
I have another pull request on opencv_extra to add test case files. |
|
I also pushed a one-line change to run the test case. Obviously it will depend on the change I made to the above referenced pull request... |
|
@kohei-us, May I ask you about the state of this PR? Have your tried to simplify it considering my comment from opencv/opencv_extra#582 (comment)? |
|
@dkurt Sorry I got caught up with something else. I will take a look at this and try your suggestion early next week. |
469b8c8 to
3c2f38d
Compare
|
@dkurt Ok. I've made changes per your suggestion, and tested it locally to make sure it still addresses my issue. |
| layerParams.set("bias_term", node_proto.input_size() == 3); | ||
|
|
||
| const DictValue* outShape = layerParams.ptr("output_shape"); | ||
| if (outShape && outShape->size() == 4) |
There was a problem hiding this comment.
- Please check if there is
"output_shape"parameter bylayerParams.has("output_shape"); - It's more convenient to use
DictValue outShape = layerParams.get("output_shape"); - If
outShape.size() != 4it's better to throw aStsNotImplementedexception because we don't know how to manage it.
| if (outShape && outShape->size() == 4) | ||
| { | ||
| const int strideY = layerParams.get<int>("stride_h"); | ||
| const int strideX = layerParams.get<int>("stride_w"); |
There was a problem hiding this comment.
Please use default values because strides might be optional:
const int strideY = layerParams.get<int>("stride_h", 1);
const int strideX = layerParams.get<int>("stride_w", 1);| { | ||
| layerParams.set("adj_w", (outW - 1) % strideX); | ||
| layerParams.set("adj_h", (outH - 1) % strideY); | ||
| } |
There was a problem hiding this comment.
What about "VALID" mode? Please see https://github.com/opencv/opencv/blob/master/modules/dnn/src/tensorflow/tf_importer.cpp for a reference code.
3c2f38d to
77e2a08
Compare
|
@dkurt Let me know if my recent change addresses all of your comments. Thanks! |
| CV_Error(Error::StsNotImplemented, | ||
| "Kernel shape attribute is required for VALID pad mode."); | ||
|
|
||
| const DictValue& kernelShape = layerParams.get("kernel_shape"); |
There was a problem hiding this comment.
It's better to use kernel_h and kernel_w (please also check that they are presented):
if (!layerParams.has("kernel_h") || !layerParams.has("kernel_w"))
CV_Error(Error::StsNotImplemented, "...");
77e2a08 to
96210fc
Compare
|
@kohei-us, The last thing I wanted to ask you is to change the base branch from |
This is relevant to cases where the net is loaded from an ONNX model containing ConvTranspose layers, which may include the output_shape attribute. c.f. https://github.com/onnx/onnx/blob/master/docs/Operators.md#ConvTranspose
96210fc to
2124205
Compare
…layer. This is related to opencv/opencv#13989.
|
Done. Hopefully I've done this correctly. I've done the same with opencv/opencv_extra#582 as well. |
Merge with extra: opencv/opencv_extra#582
This is relevant to cases where the net is loaded from an ONNX model
containing ConvTranspose layers, which may include the output_shape
attribute.
c.f. https://github.com/onnx/onnx/blob/master/docs/Operators.md#ConvTranspose