MCPcopy Create free account
hub / github.com/SooLab/CGFormer / multi_iou

Function multi_iou

utils/box_ops.py:18–27  ·  view source on GitHub ↗
(boxes1, boxes2)

Source from the content-addressed store, hash-verified

16 return iou
17
18def 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
29def box_cxcywh_to_xyxy(x):
30 x_c, y_c, w, h = x.unbind(-1)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected