matrix_nms

paddle.vision.ops. matrix_nms ( bboxes, scores, score_threshold, post_threshold, nms_top_k, keep_top_k, use_gaussian=False, gaussian_sigma=2.0, background_label=0, normalized=True, return_index=False, return_rois_num=True, name=None ) [source]

This operator does matrix non maximum suppression (NMS). First selects a subset of candidate bounding boxes that have higher scores than score_threshold (if provided), then the top k candidate is selected if nms_top_k is larger than -1. Score of the remaining candidate are then decayed according to the Matrix NMS scheme. Aftern NMS step, at most keep_top_k number of total bboxes are to be kept per image if keep_top_k is larger than -1. :param bboxes: A 3-D Tensor with shape [N, M, 4] represents the

System Message: ERROR/3 (/usr/local/lib/python3.8/site-packages/paddle/vision/ops.py:docstring of paddle.vision.ops.matrix_nms, line 9)

Unexpected indentation.

predicted locations of M bounding bboxes, N is the batch size. Each bounding box has four coordinate values and the layout is [xmin, ymin, xmax, ymax], when box size equals to 4. The data type is float32 or float64.

System Message: WARNING/2 (/usr/local/lib/python3.8/site-packages/paddle/vision/ops.py:docstring of paddle.vision.ops.matrix_nms, line 14)

Block quote ends without a blank line; unexpected unindent.

Parameters
  • scores (Tensor) – A 3-D Tensor with shape [N, C, M] represents the predicted confidence predictions. N is the batch size, C is the class number, M is number of bounding boxes. For each category there are total M scores which corresponding M bounding boxes. Please note, M is equal to the 2nd dimension of BBoxes. The data type is float32 or float64.

  • score_threshold (float) – Threshold to filter out bounding boxes with low confidence score.

  • post_threshold (float) – Threshold to filter out bounding boxes with low confidence score AFTER decaying.

  • nms_top_k (int) – Maximum number of detections to be kept according to the confidences after the filtering detections based on score_threshold.

  • keep_top_k (int) – Number of total bboxes to be kept per image after NMS step. -1 means keeping all bboxes after NMS step.

  • use_gaussian (bool) – Use Gaussian as the decay function. Default: False

  • gaussian_sigma (float) – Sigma for Gaussian decay function. Default: 2.0

  • background_label (int) – The index of background label, the background label will be ignored. If set to -1, then all categories will be considered. Default: 0

  • normalized (bool) – Whether detections are normalized. Default: True

  • return_index (bool) – Whether return selected index. Default: False

  • return_rois_num (bool) – whether return rois_num. Default: True

  • name (str) – Name of the matrix nms op. Default: None.

Returns

(Out, Index, RoisNum) if return_index is True, otherwise, a tuple with two Tensor (Out, RoisNum) is returned. Out (Tensor): A 2-D Tensor with shape [No, 6] containing the

System Message: ERROR/3 (/usr/local/lib/python3.8/site-packages/paddle/vision/ops.py:docstring of paddle.vision.ops.matrix_nms, line 56)

Unexpected indentation.

detection results. Each row has 6 values: [label, confidence, xmin, ymin, xmax, ymax]

System Message: WARNING/2 (/usr/local/lib/python3.8/site-packages/paddle/vision/ops.py:docstring of paddle.vision.ops.matrix_nms, line 58)

Block quote ends without a blank line; unexpected unindent.

Index (Tensor): A 2-D Tensor with shape [No, 1] containing the

selected indices, which are absolute values cross batches.

rois_num (Tensor): A 1-D Tensor with shape [N] containing

the number of detected boxes in each image.

Return type

A tuple with three Tensor

Examples

System Message: ERROR/3 (/usr/local/lib/python3.8/site-packages/paddle/vision/ops.py:docstring of paddle.vision.ops.matrix_nms, line 66)

Error in “code-block” directive: maximum 1 argument(s) allowed, 43 supplied.

.. code-block:: python
    import paddle
    from paddle.vision.ops import matrix_nms
    boxes = paddle.rand([4, 1, 4])
    boxes[..., 2] = boxes[..., 0] + boxes[..., 2]
    boxes[..., 3] = boxes[..., 1] + boxes[..., 3]
    scores = paddle.rand([4, 80, 1])
    out = matrix_nms(bboxes=boxes, scores=scores, background_label=0,
                         score_threshold=0.5, post_threshold=0.1,
                         nms_top_k=400, keep_top_k=200, normalized=False)