MCPcopy
hub / github.com/zetane/viewer / iou_of

Function iou_of

models/RFB_320/box_utils.py:15–31  ·  view source on GitHub ↗

Return intersection-over-union (Jaccard index) of boxes. Args: boxes0 (N, 4): ground truth boxes. boxes1 (N or 1, 4): predicted boxes. eps: a small number to avoid 0 as denominator. Returns: iou (N): IoU values.

(boxes0, boxes1, eps=1e-5)

Source from the content-addressed store, hash-verified

13 return hw[..., 0] * hw[..., 1]
14
15def iou_of(boxes0, boxes1, eps=1e-5):
16 """
17 Return intersection-over-union (Jaccard index) of boxes.
18 Args:
19 boxes0 (N, 4): ground truth boxes.
20 boxes1 (N or 1, 4): predicted boxes.
21 eps: a small number to avoid 0 as denominator.
22 Returns:
23 iou (N): IoU values.
24 """
25 overlap_left_top = np.maximum(boxes0[..., :2], boxes1[..., :2])
26 overlap_right_bottom = np.minimum(boxes0[..., 2:], boxes1[..., 2:])
27
28 overlap_area = area_of(overlap_left_top, overlap_right_bottom)
29 area0 = area_of(boxes0[..., :2], boxes0[..., 2:])
30 area1 = area_of(boxes1[..., :2], boxes1[..., 2:])
31 return overlap_area / (area0 + area1 - overlap_area + eps)
32
33def hard_nms(box_scores, iou_threshold, top_k=-1, candidate_size=200):
34 """

Callers 1

hard_nmsFunction · 0.70

Calls 1

area_ofFunction · 0.70

Tested by

no test coverage detected