(beta)torch_npu.npu_iou
接口原型
torch_npu.npu_iou(bboxes, gtboxes, mode=0) -> Tensor torch_npu.npu_ptiou(bboxes, gtboxes, mode=0) -> Tensor
功能描述
根据ground-truth和预测区域计算交并比(IoU)或前景交叉比(IoF)。
参数说明
- bboxes (Tensor) - 输入张量。
- gtboxes (Tensor) - 输入张量。
- mode (Int,默认值为0) - 0为IoU模式,1为IoF模式。
调用示例
>>> bboxes = torch.tensor([[0, 0, 10, 10],
[10, 10, 20, 20],
[32, 32, 38, 42]], dtype=torch.float16).to("npu")
>>> gtboxes = torch.tensor([[0, 0, 10, 20],
[0, 10, 10, 10],
[10, 10, 20, 20]], dtype=torch.float16).to("npu")
>>> output_iou = torch_npu.npu_iou(bboxes, gtboxes, 0)
>>> output_iou
tensor([[0.4985, 0.0000, 0.0000],
[0.0000, 0.0000, 0.0000],
[0.0000, 0.9961, 0.0000]], device='npu:0', dtype=torch.float16)
父主题: torch_npu