MCPcopy
hub / github.com/dbolya/yolact / jaccard_numpy

Function jaccard_numpy

scripts/augment_bbox.py:98–115  ·  view source on GitHub ↗

Compute the jaccard overlap of two sets of boxes. The jaccard overlap is simply the intersection over union of two boxes. E.g.: A ∩ B / A ∪ B = A ∩ B / (area(A) + area(B) - A ∩ B) Args: box_a: Multiple bounding boxes, Shape: [num_boxes,4] box_b: Single bounding b

(box_a, box_b)

Source from the content-addressed store, hash-verified

96
97
98def jaccard_numpy(box_a, box_b):
99 """Compute the jaccard overlap of two sets of boxes. The jaccard overlap
100 is simply the intersection over union of two boxes.
101 E.g.:
102 A ∩ B / A ∪ B = A ∩ B / (area(A) + area(B) - A ∩ B)
103 Args:
104 box_a: Multiple bounding boxes, Shape: [num_boxes,4]
105 box_b: Single bounding box, Shape: [4]
106 Return:
107 jaccard overlap: Shape: [box_a.shape[0], box_a.shape[1]]
108 """
109 inter = intersect(box_a, box_b)
110 area_a = ((box_a[:, 2]-box_a[:, 0]) *
111 (box_a[:, 3]-box_a[:, 1])) # [A,B]
112 area_b = ((box_b[2]-box_b[0]) *
113 (box_b[3]-box_b[1])) # [A,B]
114 union = area_a + area_b - inter
115 return inter / union # [A,B]
116
117
118def random_sample_crop(height, width, boxes=None):

Callers 1

random_sample_cropFunction · 0.70

Calls 1

intersectFunction · 0.70

Tested by

no test coverage detected