NonMaxSuppression

Description

Filters out boxes that have high intersection-over-union (IOU) overlap with previously selected boxes. Bounding boxes with score less than score_threshold are removed. The bounding box format is indicated by the center_point_box attribute.

Note that this algorithm is agnostic to where the origin is in the coordinate system and more generally is invariant to orthogonal transformations and translations of the coordinate system; thus translations or reflections of the coordinate system result in the same boxes being selected by the algorithm. The selected_indices output is a set of integers indexing into the input collection of bounding boxes representing the selected boxes. The bounding box coordinates corresponding to the selected indices can then be obtained using the Gather or GatherND operation.

Input

2-5 Input:

boxes: tensor (float) .

scores: tensor (float) .

Max_output_boxes_per_class: (optional) int64.

iou_threshold: (optional) float.

score_threshold: (optional) float.

Output

One output:

selected_indices: tensor (int64) .

Attribute

center_point_box: int. Defaults to 0. Determines the bounding box format.

  • When the value is 0, it is mainly used for the TF model. The data is provided in the form of (y1,x1,y2,x2), where (y1,x1) (y2,x2) is the coordinate of the diagonal box. You need to ensure that x1<; x2, y1<y2.
  • When the value is 1, it is mainly used for the PyTorch model. The box data is provided in the (x_center, y_center, width, height) format.

Constraints

For the Atlas 200/300/500 inference products and Atlas training products, the inputs boxes and scores support only the float16 type.

If the value of max_output_boxes_per_class is greater than 700, hardware resources may be insufficient.

The output shape of the operator on Ascend AI Processors is [max_output_boxes_per_class * batch_size * class_num, 3]. If the number of boxes found for each class is less than max_output_boxes_per_class, –1 is filled. See the following examples:

batch_size = 1

class_num = 2

max_output_boxes_per_class = 5

Three boxes are found for the first class, and one box is found for the second class. The final result is as follows:

[0, 0, 8]

[0, 0, 5]

[0, 0, 7]

[-1, -1, -1]

[-1, -1, -1]

[0, 1, 9]

[-1, -1, -1]

[-1, -1, -1]

[-1, -1, -1]

[-1, -1, -1]

ONNX Opset Support

Opset v11/v12/v13/v14/v15/v16/v17/v18