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
DNN: supports NonMaxSuppression operator from ONNX #22473
base: 4.x
Are you sure you want to change the base?
Conversation
NMSFast_(boxes, scores, score_threshold, iou_threshold, 1.0, top_k, keep_indices, rect2dOverlap, keep_top_k); | ||
|
||
// Store to output | ||
outputs[0].setTo(-1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since dnn does not support dynamic shape for now, the number of output boxes have to be set fixed (650 is used in this implementation, but there will not be so many boxes in one single image typically speaking). So invalid indices have to be set to -1.
@rogday if the nms operator is ported from torchvision.ops.nms
, the NonMaxSuppression operator is always followed by a Gather operator (see the visualization in opencv/opencv_extra#1005). I wonder if it is reasonable to drop those invalid indices in your pull request for the Gather operator.
I would like to postphone this pull request, since I cannot find a workaround for the dynamic output of nms. Will get back to this pull request when we have next gen dnn which supports dynamic shape. |
Can this op fit to |
Yes and no. They all do NMS but DetectionOutput layer tries to generate priors and decode bboxes as well, which are not needed in the NonMaxSuppression operator from ONNX. Another problem is DetectionOutput layer has |
I were not able to find NonMaxSuppression layers in SSD-MobilenetV1 and SSD-MobilenetV1-12 models. |
It is in the subgraph of the second |
@fengyuentau, cannot find it, maybe model has been updated? |
Click on |
Fixes #19779. And one step forward to support the ssd-mobilenet from onnx model zoo.
opencv/opencv_extra#1005
TODO list:
torchvision.ops.nms
to ONNX.torchvision.ops.batched_nms
to ONNX.Pull Request Readiness Checklist
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.