infer.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:cnn_polyp_detection 作者: odysszis 项目源码 文件源码
def calc_detection_rate(prediction,label):
    '''
    Calculate the detection True Positives, False Negatives and False Positives.
    TP occurs whenever the prediction region intersects the ground truth region.
    FP occurs 
    '''
    label_temp=np.copy(label)   
    TP=FN=FP=0.0
    # pattern for ndimage neighbouring pixels
    s = [[1,1,1],
        [1,1,1],
        [1,1,1]]
    labeled_prediction, num_features_prediction = ndimage.label(prediction, structure=s)
    labeled_label, num_features_label = ndimage.label(label_temp, structure=s)
    for i in range(1,num_features_prediction+1):
        intersection=np.sum(labeled_prediction[label==1]==i)
        if intersection>0:
            TP+=1
        else:
            FP+=1
    for i in range(1,num_features_label+1):
        intersection=np.sum(labeled_label[prediction==1]==i)
        if intersection==0:
            FN=+1
    return TP,FN,FP
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号