(boxes1, boxes2)
| 21 | |
| 22 | |
| 23 | def box_ioa(boxes1, boxes2): |
| 24 | area1 = box_area(boxes1) |
| 25 | |
| 26 | lt = torch.max(boxes1[:, None, :2], boxes2[:, :2]) # [N,M,2] |
| 27 | rb = torch.min(boxes1[:, None, 2:], boxes2[:, 2:]) # [N,M,2] |
| 28 | |
| 29 | wh = (rb - lt).clamp(min=0) # [N,M,2] |
| 30 | inter = wh[:, :, 0] * wh[:, :, 1] # [N,M] |
| 31 | |
| 32 | return inter / area1[:, None] |
| 33 | |
| 34 | |
| 35 | # modified from torchvision to also return the union |
nothing calls this directly
no outgoing calls
no test coverage detected