Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added dynamic input support to Pad layer #25606

Closed
wants to merge 3 commits into from

Conversation

LaurentBerger
Copy link
Contributor

@LaurentBerger LaurentBerger commented May 17, 2024

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

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

onnx model :
image

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]

@LaurentBerger LaurentBerger marked this pull request as draft May 17, 2024 14:21
@LaurentBerger
Copy link
Contributor Author

@fengyuentau what does it mean 😕?

@asmorkalov asmorkalov changed the title Dnndyn Added dynamic input support to Pad layer May 20, 2024
@asmorkalov asmorkalov added feature category: dnn (onnx) ONNX suport issues in DNN module labels May 20, 2024
@asmorkalov asmorkalov added this to the 5.0 milestone May 20, 2024
@LaurentBerger
Copy link
Contributor Author

LaurentBerger commented May 21, 2024

now opencv is compatible vit_l_encoder.onnx (Segment Anything Model)

@fengyuentau
Copy link
Member

Your code breaks the design of dnn, making it even harder to maintain.

@LaurentBerger
Copy link
Contributor Author

Your code breaks the design of dnn, making it even harder to maintain.

All opencv dnn test are OK in thiscode Opencv cannot read vit_l_encoder.onnx and make inference this code can read and make inference. I check result with onnxruntime and resuts are good
So what is broken?

@LaurentBerger LaurentBerger marked this pull request as ready for review May 21, 2024 09:42
@LaurentBerger
Copy link
Contributor Author

moving to onnxruntime for dnn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: dnn (onnx) ONNX suport issues in DNN module feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants