nn/nn_utils.py
def iou_metric(truth, pred, truth_val=1, divide_flag=False):
    """
    calculate iou with given truth and prediction map
    :param truth: truth image
    :param pred: prediction map
    :param truth_val: truth value, default to 1
    :param divide_flag: if False, numerator and denominator will be returned separately
    :return: iou scalar value or numerator and denominator list
    """
    truth = truth / truth_val
    pred = pred / truth_val
    truth = truth.flatten()
    pred = pred.flatten()
    intersect = truth*pred
    if divide_flag:
        return np.sum(intersect == 1), np.sum(truth+pred >= 1)
    else:
        return np.sum(intersect == 1) / np.sum(truth+pred >= 1)

    calculate iou with given truth and prediction map
    :param truth: truth image
    :param pred: prediction map
    :param truth_val: truth value, default to 1
    :param divide_flag: if False, numerator and denominator will be returned separately
    :return: iou scalar value or numerator and denominator list
    
calculate iou with given truth and prediction map
calculate iou with given truth and prediction map
def iou_metric(truth, pred, truth_val=1, divide_flag=False):
    truth = truth / truth_val
    pred = pred / truth_val
    truth = truth.flatten()
    pred = pred.flatten()
    intersect = truth*pred
    if divide_flag:
        return np.sum(intersect == 1), np.sum(truth+pred >= 1)
    else:
        return np.sum(intersect == 1) / np.sum(truth+pred >= 1)
def iou_metric ( truth , pred , truth_val = 1 , divide_flag = False ) : truth = truth / truth_val pred = pred / truth_val truth = truth . flatten ( ) pred = pred . flatten ( ) intersect = truth * pred if divide_flag : return np . sum ( intersect == 1 ) , np . sum ( truth + pred >= 1 ) else : return np . sum ( intersect == 1 ) / np . sum ( truth + pred >= 1 )
calculate iou with given truth and prediction map
calculate iou with given truth and prediction map
"""
    calculate iou with given truth and prediction map
    :param truth: truth image
    :param pred: prediction map
    :param truth_val: truth value, default to 1
    :param divide_flag: if False, numerator and denominator will be returned separately
    :return: iou scalar value or numerator and denominator list
    """
iou scalar value or numerator and denominator list
iou scalar value or numerator and denominator list
truth
None
pred
None
truth_val
truth value, default to 1
truth value default to 1
divide_flag
if False, numerator and denominator will be returned separately
if False numerator and denominator will be returned separately