Skip to content

DNN : fix bug in extracting prior-box variances in detection output layer#20525

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
jebastin-nadar:fix-prior-variances
Aug 13, 2021
Merged

DNN : fix bug in extracting prior-box variances in detection output layer#20525
opencv-pushbot merged 1 commit intoopencv:3.4from
jebastin-nadar:fix-prior-variances

Conversation

@jebastin-nadar
Copy link
Copy Markdown
Contributor

GetPriorBBoxes() assumes the input blob has shape (1, 2, num_priors * 4, 1) with the second channel being prior-box variances. But when _varianceEncodedInTarget is true, the input has shape (1, 1, num_prioirs * 4, 1), as checked by the following assertion

CV_Assert(inputs[2][1] == 1 + (int)(!_varianceEncodedInTarget));

Another reference in the reshape for the input of Detection output layer in faster-rcnn-vgg16.

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 other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to 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

@alalek
Copy link
Copy Markdown
Member

alalek commented Aug 9, 2021

@SamFC10 Thank you for contribution!
Is it possible to add accuracy test for this case?

@jebastin-nadar
Copy link
Copy Markdown
Contributor Author

Is it possible to add accuracy test for this case?

There were some faster rcnn tests which crashed sporadically in my int8 PR (#20228) on Windows CI builders and local windows machine with the message - unknown file: error: SEH exception with code 0xc0000005 thrown in the test body. Tracing back, it was the illegal memory access in prior-box variances which caused these crashes. I don't know how to reproduce these sporadic crashes in a test. Will need some help.

@asmorkalov asmorkalov removed the request for review from JulieBar August 11, 2021 06:50
@alalek
Copy link
Copy Markdown
Member

alalek commented Aug 11, 2021

Tracing back, it was the illegal memory access in prior-box variances which caused these crashes.

This usually happens when memory is accessed without checking arrays layouts (through CV_Check* or CV_Assert macros). It makes sense to add these checks there.

@jebastin-nadar
Copy link
Copy Markdown
Contributor Author

add these checks there

There is one already

CV_Assert(inputs[2][1] == 1 + (int)(!_varianceEncodedInTarget));

It was added in #11255 but the function GetPriorBBoxes() wasn't modified along with the added assertion.

@asmorkalov asmorkalov requested a review from rogday August 12, 2021 08:17
@vpisarev vpisarev self-requested a review August 13, 2021 08:29
@vpisarev vpisarev self-assigned this Aug 13, 2021
@vpisarev
Copy link
Copy Markdown
Contributor

👍

@opencv-pushbot opencv-pushbot merged commit 9d3826c into opencv:3.4 Aug 13, 2021
@alalek alalek mentioned this pull request Aug 14, 2021
@jebastin-nadar jebastin-nadar deleted the fix-prior-variances branch August 19, 2021 04:51
@alalek alalek mentioned this pull request Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants