mmdetection如何计算准确率、召回率、F1值

本文介绍了使用Python脚本对FCOS(FullyConvolutionalOneStageObjectDetection)模型进行训练,测试过程中加入`--out=result.pkl`参数以计算精度和召回率,并在`confusion_matrix.py`中计算并展示了各项指标如精确度、召回率和F1分数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、训练

python tools/train.py configs/fcos/fcosrdweed3.py  

2、测试
这一步要加–out=result.pkl,才能计算准确率和召回率

python tools/test.py configs/fcos/fcosrddweed3.py work_dirs/fcosrddweed3/epoch_300.pth --out=resultfcos.pkl

3、计算准确率和召回率
在tools/analysis_tools/confusion_matrix.py代码下面加上:

	TP = np.diag(confusion_matrix)
    FP = np.sum(confusion_matrix, axis=0) - TP
    FN = np.sum(confusion_matrix, axis=1) - TP

    precision = TP / (TP + FP)
    recall = TP / (TP + FN)
    average_precision = np.mean(precision)
    average_recall = np.mean(recall)
    f1 = 2 * (average_precision * average_recall) / (average_precision + average_recall)
    #print("AP ", average_precision)
    #print("AR", average_recall)
    #print("F1", f1)
    print("P",precision)
    print("R",recall)

在这里插入图片描述

运行:

python tools/analysis_tools/confusion_matrix.py configs/fcos/fcosrddweed3.py resultfcos.pkl  ./ 

拿下:
在这里插入图片描述

评论 15
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

毕竟是shy哥

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值