


The offset is dependent # only on the class idx, and is large enough so that boxes # from different classes do not overlap if boxes. _script_if_tracing def _batched_nms_coordinate_trick ( boxes : Tensor, scores : Tensor, idxs : Tensor, iou_threshold : float, ) -> Tensor : # strategy: in order to perform NMS independently per class, # we add an offset to all the boxes. _is_tracing (): return _batched_nms_vanilla ( boxes, scores, idxs, iou_threshold ) else : return _batched_nms_coordinate_trick ( boxes, scores, idxs, iou_threshold ).

type = "cpu" else 20000 ) and not torchvision. is_tracing (): _log_api_usage_once ( batched_nms ) # Benchmarks that drove the following thresholds are at # if boxes. They are expected to be in ``(x1, y1, x2, y2)`` format with ``0 iou_threshold Returns: Tensor: int64 tensor with the indices of the elements that have been kept by NMS, sorted in decreasing order of scores """ if not torch. Args: boxes (Tensor): boxes where NMS will be performed. Each index value correspond to a category, and NMS will not be applied between elements of different categories. def batched_nms ( boxes : Tensor, scores : Tensor, idxs : Tensor, iou_threshold : float, ) -> Tensor : """ Performs non-maximum suppression in a batched fashion. is_tracing (): _log_api_usage_once ( nms ) _assert_has_ops () return torch. Args: boxes (Tensor)): boxes to perform NMS on. This is similar to the behavior of argsort in PyTorch when repeated values are present. 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. NMS iteratively removes lower scoring boxes which have an IoU greater than iou_threshold with another (higher scoring) box. Def nms ( boxes : Tensor, scores : Tensor, iou_threshold : float ) -> Tensor : """ Performs non-maximum suppression (NMS) on the boxes according to their intersection-over-union (IoU).
