(boxes1, boxes2)
| 16 | return iou |
| 17 | |
| 18 | def multi_iou(boxes1, boxes2): |
| 19 | lt = torch.max(boxes1[...,:2], boxes2[...,:2]) |
| 20 | rb = torch.min(boxes1[...,2:], boxes2[...,2:]) |
| 21 | wh = (rb - lt).clamp(min=0) |
| 22 | wh_1 = boxes1[...,2:] - boxes1[...,:2] |
| 23 | wh_2 = boxes2[...,2:] - boxes2[...,:2] |
| 24 | inter = wh[...,0] * wh[...,1] |
| 25 | union = wh_1[...,0] * wh_1[...,1] + wh_2[...,0] * wh_2[...,1] - inter |
| 26 | iou = (inter + 1e-6) / (union + 1e-6) |
| 27 | return iou |
| 28 | |
| 29 | def box_cxcywh_to_xyxy(x): |
| 30 | x_c, y_c, w, h = x.unbind(-1) |
nothing calls this directly
no outgoing calls
no test coverage detected