Skip to content

WeChatQR-fix conversion Caffe to ONNX #4

Open
omrope79 wants to merge 1 commit into5.xfrom
wechat-fix
Open

WeChatQR-fix conversion Caffe to ONNX #4
omrope79 wants to merge 1 commit into5.xfrom
wechat-fix

Conversation

@omrope79
Copy link
Copy Markdown
Owner

@omrope79 omrope79 commented Apr 1, 2026

Pull Request Readiness Checklist

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

Comment on lines +837 to +872
{
const Mat& out0 = outputs[0];
bool needsCrop = false;
for (const auto& inp : used_inputs) {
int delta = out0.dims - inp.dims;
for (int d = 0; d < inp.dims; d++) {
int od = d + delta;
if (od >= 0 && inp.size[d] > 1 && out0.size[od] > 1 &&
inp.size[d] != out0.size[od]) {
needsCrop = true; break;
}
}
if (needsCrop) break;
}
if (needsCrop) {
std::vector<Range> ranges;
for (size_t k = 0; k < used_inputs.size(); k++) {
Mat& inp = used_inputs[k];
int delta = out0.dims - inp.dims;
bool modified = false;
ranges.assign(inp.dims, Range::all());
for (int d = 0; d < inp.dims; d++) {
int od = d + delta;
if (od >= 0 && inp.size[d] > out0.size[od] &&
inp.size[d] > 1 && out0.size[od] > 1) {
ranges[d] = Range(0, out0.size[od]);
modified = true;
}
}
if (modified)
inp = inp(ranges).clone();
}
helper.init(used_inputs, outputs);
CV_CheckTrue(helper.prepare_for_broadcast_op(), "NaryEltwiseLayer: Preparation for broadcasting failed");
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

fix the code formatting. There is a unnecessary bracket {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants