Skip to content

dnn: assertion failure with multiple images #13626

Open

Description

@berak
  • OpenCV => 4.0.1-dev
  • Operating System / Platform => Windows 64 Bit
  • Compiler => mingw64 7.2.0
Detailed description

using the face_detector_uint8.pb model with multiple images (using dnn::blobFromImages), i get :

OpenCV(4.0.1-dev) Error: Assertion failed (start <= (int)shape.size() && end <= (int)shape.size() && start <= end) in total, file C:/p/opencv/modules/dnn/include/opencv
2/dnn/shape_utils.hpp, line 161

debugging it, i found, that in the 2nd ScaleLayer, the endAxis exceeds the size of the inpShape:

Thread 1 hit Breakpoint 9, cv::dnn::ScaleLayerImpl::forward (this=0xa5c1090, inputs_arr=..., outputs_arr=..., internals_arr=...)
    at C:\p\opencv\modules\dnn\src\layers\scale_layer.cpp:94
94              CV_Assert(total(inpShape, axis, endAxis) == numWeights);
(gdb) p inpShape
$16 = std::vector of length 4, capacity 4 = {3, 32, 24, 32}
(gdb) p axis
$17 = 0
(gdb) p endAxis
$18 = 5 // this is 2 with one image, and 5 with 3 of them !

thus the assert fails here:

CV_Assert(start <= (int)shape.size() && end <= (int)shape.size() &&
start <= end);

Steps to reproduce
```
dnn::Net net = dnn::readNetFromTensorflow("opencv_face_detector_uint8.pb","opencv_face_detector.pbtxt");
Mat f1=imread("../img/h1.png");
Mat f2=imread("../img/h2.png");
Mat f3=imread("../img/h3.png");
vector<Mat> vf {f1, f2, f3};
Mat blob = dnn::blobFromImages(vf, 1, Size(128,96), Scalar(104, 177, 123, 0), false, false);
net.setInput(blob);
Mat res = net.forward("detection_out");
```

Activity

  1. AyushP123 commented on Jan 16, 2019

    @AyushP123
    Contributor

    can I assign this to myself, it seems like a good first bug.

  2. Mancancode commented on Mar 15, 2019

    @Mancancode
  3. berak commented on Mar 15, 2019

    @berak
    Author
  4. alalek commented on Dec 24, 2021

    @alalek
    Member

    probably related to #16630

  5. asmorkalov commented on May 18, 2023

    @asmorkalov
    Contributor

    @fengyuentau Could you take a look?

  6. modified the milestones: 3.4.20, 4.9.0 on Jun 9, 2023
  7. added
    affected: 3.4
    on Jun 9, 2023
  8. modified the milestones: 4.9.0, 4.10.0 on Dec 1, 2023
  9. modified the milestones: 4.10.0, 4.11.0 on May 3, 2024
  10. removed this from the 4.11.0 milestone on Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

affected: 3.4bugcategory: dnn

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions