MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / box_iou

Function box_iou

PATH/core/models/ops/box_ops.py:36–49  ·  view source on GitHub ↗
(boxes1, boxes2)

Source from the content-addressed store, hash-verified

34
35# modified from torchvision to also return the union
36def box_iou(boxes1, boxes2):
37 area1 = box_area(boxes1)
38 area2 = box_area(boxes2)
39
40 lt = torch.max(boxes1[:, None, :2], boxes2[:, :2]) # [N,M,2]
41 rb = torch.min(boxes1[:, None, 2:], boxes2[:, 2:]) # [N,M,2]
42
43 wh = (rb - lt).clamp(min=0) # [N,M,2]
44 inter = wh[:, :, 0] * wh[:, :, 1] # [N,M]
45
46 union = area1[:, None] + area2 - inter
47
48 iou = inter / union
49 return iou, union
50
51
52def generalized_box_iou(boxes1, boxes2):

Callers 2

generalized_box_iouFunction · 0.85
giou_iouFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected