深度学习常用评价指标汇总

一、2D图像分割任务

1.像素精度 (Pixel Accuracy, PA)

PA = \frac{\sum_{i=0}^{k}P_{ii}}{\sum_{i=0}^{k}\sum_{j=0}^{k}P_{ij}}

2.平均像素精度(mean Pixel Accuracy, mPA)

每个类内被正确分类像素数的比例,之后求所有类的平均,k为类别数,+1为背景

mPA = \frac{1}{k+1}\sum_{i=0}^{k}\frac{P_{ii}}{\sum_{j=0}^{k}P_{ij}}

3.平均交并比(mean Intersection over Union, mIoU)

计算两个集合的交集和并集之比,在每个类上求IoU,之后取平均

mIoU = \frac{1}{k+1}\sum_{i=0}^{k}\frac{P_{ii}}{\sum_{j=0}^{k}P_{ij} + \sum_{j=0}^{k}P_{ji} - P_{ii}}

二、3D点云分割任务

1.平均交并比

代码示例(两种方法代码)

"""计算一个批次下的mIoU
"""
import numpy as np


NUM_CLASSES = 17
total_seen_class = [0 for _ in range(NUM_CLASSES)]
total_intersection_class = [0 for _ in range(NUM_CLASSES)]
total_union_class = [0 for _ in range(NUM_CLASSES)]
# label为标签真值数组,pred为标签预测数组
for index in range(NUM_CLASSES):
    total_seen_class[index] += np.sum((label == index))                             # 求该index类总元素个数
    total_intersection_class[index] += np.sum((pred == index) & (label == index))   # 求真值为index且同样预测为index的元素个数,对应于IoU公式中的分子————交
    total_union_class[index] += np.sum(((pred == index) | (label == index)))        # 求真值为index或者预测为index的元素个数,对应于IoU公式中的分母————并
mIoU = np.mean(np.array(total_intersection_class) / (np.array(total_union_class, dtype=np.float) + 1e-6))



"""计算每一个批次batch的mIoU, acc
"""
import numpy as np

num_classes = 17
batchs = target.shape[0]

# 计算acc
correct = pred.eq(target.data).cpu().sum()

# 计算mIoU
shape_ious = []
for batch_idx in range(batchs):     # target.shape是batch大小
    parts = range(num_classes)
    class_ious = []
    for part in parts:
        I = np.sum(np.logical_and(pred[batch_idx] == part, target[batch_idx] == part))
        U = np.sum(np.logical_or(pred[batch_idx] == part, target[batch_idx] == part))
        if U == 0:
            iou = 1 #If the union of groundtruth and prediction points is empty, then count part IoU as 1
        else:
            iou = I / float(U)
        class_ious.append(iou)
    pass        # 该对象,每一类的IoU计算完毕
    shape_ious.append(np.mean(class_ious))
    mIoU = np.mean(shape_ious)
    acc = correct.item()/float(batchs * 50000)
pass

 三、2D目标检测

1.平均精度(Average Precision, AP)

confidence:定一个阈值threshold,规定当检测框的置信度confidence > threshold时,才认定该预测框有效。

IoU:定一个阈值threshold,规定当检测框真值与预测IoU > threshold时,才认定为预测成功。

TP:True Positive,真阳,真值为正,预测为正,预测对了

FP:False Positive,假阳,真值为负,预测为正,预测错了

FN:False Negative,假阴,真值为正,预测为负,漏检了

TN:True Negative,真阴,真值为负,预测为负

(1)Precision——精确度,查准率

表示预测为正的结果中有多少样本是正确的

P = \frac{TP}{TP + FP}

(2)Recall——召回率,查全率

表示正样本结果中有多少正样本被正确检测出来

R = \frac{TP}{TP + FN}

(3)P-R曲线

IoU取不同的值,则有不同的TP、FP、FN值,相应的,就会有不同的P、R,以R为横坐标,P为纵坐标,则可以画出一条曲线,成为P-R曲线。P-R曲线的下方面积则为最终的AP,不同类别的AP取平均值,则为mAP

代码示例:(参考目标检测中的mAP+PyTorch实现_pytorch pred gt-CSDN博客,暂未测试)

四、参考条目

目标检测mAP计算以及coco评价标准_哔哩哔哩_bilibili

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值