def bb_iou_dice(boxa, boxb):
    """IoU and Dice for bbox"""
    x_min = max(boxa[0], boxb[0])
    y_min = max(boxa[1], boxb[1])
    x_max = min(boxa[2], boxb[0] + boxb[2])
    y_max = min(boxa[3], boxb[1] + boxb[3])

    inter_area = (x_max - x_min) * (y_max - y_min)

    boxa_area = (boxa[2]-boxa[0]) * (boxa[3] - boxa[1])
    boxb_area = boxb[2] * boxb[3]

    iou = inter_area / float(boxa_area + boxb_area - inter_area)
    dice = (2 * inter_area) / float(boxa_area + boxb_area)

    return iou, dice