Table of Contents
Shortcuts

# nms

torchvision.ops.nms(boxes: Tensor, scores: Tensor, iou_threshold: float) → Tensor

  Performs non-maximum suppression (NMS) on the boxes according to their intersection-over-union (IoU).

  NMS iteratively removes lower scoring boxes which have an IoU greater than iou_threshold with another (higher scoring) box.

  If multiple boxes have the exact same score and satisfy the IoU criterion with respect to a reference box, the selected box is not guaranteed to be the same between CPU and GPU. This is similar to the behavior of argsort in PyTorch when repeated values are present.

  Parameters:

    - boxes (Tensor[N, 4])) – boxes to perform NMS on. They are expected to be in `(x1, y1, x2, y2)` format with `0 <= x1 < x2` and `0 <= y1 < y2`.

    - scores (Tensor[N]) – scores for each one of the boxes

    - iou_threshold (float) – discards all overlapping boxes with IoU > iou_threshold

  Returns:

    int64 tensor with the indices of the elements that have been kept by NMS, sorted in decreasing order of scores

  Return type:

    Tensor

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.