Shortcuts

batched_nms

torchvision.ops.batched_nms(boxes: Tensor, scores: Tensor, idxs: Tensor, iou_threshold: float) Tensor[source]

以批处理方式执行非最大抑制。

每个索引值对应一个类别,NMS不会在不同类别的元素之间应用。

Parameters:
  • boxes (Tensor[N, 4]) – 将执行NMS的框。它们预计以(x1, y1, x2, y2)格式表示,且满足0 <= x1 < x20 <= y1 < y2

  • scores (Tensor[N]) – 每个框的分数

  • idxs (Tensor[N]) – 每个框的类别索引。

  • iou_threshold (float) – 丢弃所有与IoU大于iou_threshold的重叠框

Returns:

int64 张量,包含被 NMS 保留的元素的索引,按分数降序排序

Return type:

张量