Added dynamic input support to Pad layer #25606
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Readiness Checklist
Question : Is opencv team want to solve bug #24729 and #25118?
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.
onnx model :
test_pad_add.zip
this model has a dynamic Pad layer : padding values are output result of Concat layer
I use this program :
cv::dnn::Net x1 = cv::dnn::readNet("test_pad_add.onnx");
std::vector sza = { 2, 1 };
Mat inpa = (Mat_(2, 1) << 1, 2);
Mat inpb = (Mat_(2, 1) << 3, 1);
Mat inpx = (Mat_(3, 2) << 10, 11, 12, 13, 14, 15);
x1.setInput(inpa, "inpa");
x1.setInput(inpb, "inpb");
x1.setInput(inpx, "inpx");
std::vector res(3);
x1.forward(res, std::vector< String >{ "out_add", "pad_values", "out_pad" });
displayBlobSize(res[0], "\nout_add");
displayBlob(res[0], "out_add");
displayBlobSize(res[1], "\npad_values");
displayBlob(res[1], "pad_values");
displayBlobSize(res[2], "\nout_pad");
displayBlob(res[2], "out_pad");
and result
out_add blob size
dim 0 : 6 dim 1 : 6
out_add =
[2, 2, 2, 2, 2, 2;
2, 2, 2, 12, 13, 2;
2, 2, 2, 14, 15, 2;
2, 2, 2, 16, 17, 2;
2, 2, 2, 2, 2, 2;
2, 2, 2, 2, 2, 2]
pad_values blob size
dim 0 : 4 dim 1 : 1
pad_values =
[1;
2;
3;
1]
out_pad blob size
dim 0 : 6 dim 1 : 6
out_pad =
[0, 0, 0, 0, 0, 0;
0, 0, 0, 10, 11, 0;
0, 0, 0, 12, 13, 0;
0, 0, 0, 14, 15, 0;
0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0]