Skip to content

Batched NMSBoxes #22851

@fengyuentau

Description

@fengyuentau

Descripe the feature and motivation

Batched NMS is especially useful for modern generic object detection postprocessing. Generic object detection has multiple classes, and it is important to perform NMS on each class to give correct results. However, the existing API for NMS in dnn module NMSBoxes does not support multiple classes.

We can use the same strategy from https://github.com/pytorch/vision/blob/main/torchvision/ops/boxes.py#L79-L95 to implement batched NMS:

  1. get the maximum coordinate from boxes,
  2. calculate the offset based on the maximum coordinate and class ids,
  3. add offsets to boxes,
  4. run NMSBoxes with boxes with offsets, scores and thresholds.

Although this is quite simple to implement for experienced developers, it would still be better if we put it in the dnn module as a new API (Let's call it BatchedNMSBoxes), and it can be done by calling a single API instead of wasting time implementing every time we need it.

Additional context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions