文章目录
IoU手写
def iou(box1, box2):
# box left right top bottom
t_h = min(box1[3], box2[3]) - max(box1[2], box2[3])
t_w = min(box1[1], box2[1]) - max(box1[0], box2[0])
inter = 0 if t_h <0 or t_w <0 else t_h*t_w
union = (box1[3] - box1[2])*(box1[1]-box1[0]) + (box2[3] - box2[2])*(box2[1]-box2[0])-inter
return inter/union