def xyxy_iou(box1,box2):
    """
    calculate iou between box1 and box2
    :param box1: (4, ), format (left, upper, right, bottom)
    :param box1: (4, ), format (left, upper, right, bottom)
    :return: float, iou score
    """
    l_max = max(box1[0], box2[0])
    r_min = min(box1[2], box2[2])
    u_max = max(box1[1], box2[1])
    b_min = min(box1[3], box2[3])

    if l_max>=r_min or u_max>=b_min:
        return 0
    else:
        area1 = (box1[2]-box1[0])*(box1[3]-box1[1])
        area2 = (box2[2]-box2[0])*(box2[3]-box2[1])
        area_i = (b_min-u_max)*(r_min-l_max)
        return area_i/(area1+area2-area_i)