(boxes1,boxes2)
| 5 | from torchvision.ops.boxes import box_area |
| 6 | |
| 7 | def clip_iou(boxes1,boxes2): |
| 8 | area1 = box_area(boxes1) |
| 9 | area2 = box_area(boxes2) |
| 10 | lt = torch.max(boxes1[:, :2], boxes2[:, :2]) |
| 11 | rb = torch.min(boxes1[:, 2:], boxes2[:, 2:]) |
| 12 | wh = (rb - lt).clamp(min=0) |
| 13 | inter = wh[:,0] * wh[:,1] |
| 14 | union = area1 + area2 - inter |
| 15 | iou = (inter + 1e-6) / (union+1e-6) |
| 16 | return iou |
| 17 | |
| 18 | def multi_iou(boxes1, boxes2): |
| 19 | lt = torch.max(boxes1[...,:2], boxes2[...,:2]) |
nothing calls this directly
no outgoing calls
no test coverage detected