faster rcnn 中mAP、ap、precision和recall解析(多类平均正确率、平均正确率、精确率和召回率)

https://blog.csdn.net/a1154761720/article/details/50864994
https://blog.csdn.net/hysteric314/article/details/54093734
https://www.cnblogs.com/shixiangwan/p/7215926.html?utm_source=itdadao&utm_medium=referral请参考以上链接,你的疑惑就消除了。

P=检测正确/(检测正确+检测误以为正确)   R=检测正确/(检测正确+检测误以为错误)

下面我主要说一下faster rcnn关于ap的计算:

根目录lib/dataset 下voc_eval.py有这样的代码

def voc_ap(rec, prec, use_07_metric=False):
    """ ap = voc_ap(rec, prec, [use_07_metric])
    Compute VOC AP given precision and recall.
    If use_07_metric is true, uses the
    VOC 07 11 point method (default:False).
    """
    if use_07_metric:
        # 11 point metric
        ap = 0.
        for t in np.arange(0., 1.1, 0.1):
            if np.sum(rec >= t) == 0:
                p = 0
            else:
                p = np.max(prec[rec >= t])
            ap = ap + p / 11.
    else:
        # correct AP calculation
        # first append sentinel values at the end
        mrec = np.concatenate(([0.], rec, [1.]))
        mpre = np.concatenate(([0.], prec, [0.]))

        # compute the precision envelope
        for i in range(mpre.size - 1, 0, -1):
            mpre[i - 1] = np.maximum(mpre[i - 1], mpre[i])

        # to calculate area under PR curve, look for points
        # where X axis (recall) changes value
        i = np.where(mrec[1:] != mrec[:-1])[0]

        # and sum (\Delta recall) * prec
        ap = np.sum((mrec[i + 1] - mrec[i]) * mpre[i + 1])
    return ap

什么意思呢?如果你的数据集是voc2007,ap就取最大的精确率,11点取平均循环加起来。否则,比如数据集voc2012那么就使用precision和recall积分求面积得到ap。你可以把此法用到voc2007上也没有关系,我就是这样做的。

感谢三个链接作者对我的启发帮助!

  • 6
    点赞
  • 33
    收藏
    觉得还不错? 一键收藏
  • 38
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值