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

Function clip_iou

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

Source from the content-addressed store, hash-verified

5from torchvision.ops.boxes import box_area
6
7def 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
18def multi_iou(boxes1, boxes2):
19 lt = torch.max(boxes1[...,:2], boxes2[...,:2])

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected