MCPcopy
hub / github.com/microsoft/Magma / IoU

Function IoU

agents/ui_agent/util/utils.py:191–199  ·  view source on GitHub ↗
(box1, box2)

Source from the content-addressed store, hash-verified

189 return max(0, x2 - x1) * max(0, y2 - y1)
190
191 def IoU(box1, box2):
192 intersection = intersection_area(box1, box2)
193 union = box_area(box1) + box_area(box2) - intersection + 1e-6
194 if box_area(box1) > 0 and box_area(box2) > 0:
195 ratio1 = intersection / box_area(box1)
196 ratio2 = intersection / box_area(box2)
197 else:
198 ratio1, ratio2 = 0, 0
199 return max(intersection / union, ratio1, ratio2)
200
201 def is_inside(box1, box2):
202 # return box1[0] >= box2[0] and box1[1] >= box2[1] and box1[2] <= box2[2] and box1[3] <= box2[3]

Callers 2

remove_overlapFunction · 0.70
remove_overlap_newFunction · 0.70

Calls 2

intersection_areaFunction · 0.70
box_areaFunction · 0.70

Tested by

no test coverage detected