torch_npu.contrib.function.npu_batched_multiclass_nms(multi_bboxes,multi_scores,score_thr=0.05,nms_thr=0.45,max_num=50,score_factors=None):
使用NPU API的批量多类bbox NMS。
Tuple - (bboxes, labels),shape为(bs, k, 5)和(bs, k, 1)的张量。标签以0为基础。
在动态shape条件下,由于NPU op的限制,最多支持20个类别(nmsed_classes)和10000个框(nmsed_boxes)。
1 2 3 4 | >>> from torch_npu.contrib.function import npu_batched_multiclass_nms >>> boxes = torch.randint(1, 255, size=(4, 200, 80, 4)).npu().half() >>> scores = torch.randn(4, 200, 81).npu().half() >>> det_bboxes, det_labels = npu_batched_multiclass_nms(boxes, scores, score_thr=0.3, nms_thr=0.5, max_num=3) |