def _dense_iou(gt, pred, gt_crowd=False):
    """Computes the IoU between the given ground truth and predicted
    detection masks.

    Args:
        gt: a :class:`fiftyone.core.labels.Detection`
        pred: a :class:`fiftyone.core.labels.Detection`
        gt_crowd (False): whether the ground truth object is a crowd

    Returns:
        the IoU, in ``[0, 1]``
    """
    gt_mask = gt.mask
    gt_bb = gt.bounding_box  # x,y,w,h of box
    gt_mask_h, gt_mask_w = gt_mask.shape

    pred_mask = pred.mask
    pred_bb = pred.bounding_box  # x,y,w,h of box
    pred_mask_h, pred_mask_w = pred_mask.shape

    gt_img_w = round(gt_mask_w / gt_bb[2])
    gt_img_h = round(gt_mask_h / gt_bb[3])

    pred_img_w = round(pred_mask_w / pred_bb[2])
    pred_img_h = round(pred_mask_h / pred_bb[3])

    gt_mask_full = np.zeros((gt_img_h, gt_img_w))
    pred_mask_full = np.zeros((pred_img_h, pred_img_w))

    x1, y1, x2, y2 = _float_to_pixel(gt_bb, gt_img_w, gt_img_h)
    gt_mask_full[y1:y2, x1:x2] = gt_mask

    x1, y1, x2, y2 = _float_to_pixel(pred_bb, pred_img_w, pred_img_h)
    pred_mask_full[y1:y2, x1:x2] = pred_mask

    if gt_img_w != pred_img_w or gt_img_h != pred_img_h:
        gt_size = gt_img_w * gt_img_h
        pred_size = pred_img_w * pred_img_h
        if gt_size > pred_size:
            pred_mask_full = etai.resize(
                pred_mask_full,
                height=gt_img_h,
                width=gt_img_w,
                interpolation=0,  # equivalent to cv2.INTER_NEAREST
            )
        else:
            gt_mask_full = etai.resize(
                gt_mask_full,
                height=pred_img_h,
                width=pred_img_w,
                interpolation=0,  # equivalent to cv2.INTER_NEAREST
            )

    inter = np.logical_and(gt_mask_full, pred_mask_full).sum()
    union = np.logical_or(gt_mask_full, pred_mask_full).sum()

    return min(etan.safe_divide(inter, union), 1)
Computes the IoU between the given ground truth and predicted
    detection masks.

    Args:
        gt: a :class:`fiftyone.core.labels.Detection`
        pred: a :class:`fiftyone.core.labels.Detection`
        gt_crowd (False): whether the ground truth object is a crowd

    Returns:
        the IoU, in ``[0, 1]``
    
fiftyone/utils/iou.py