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

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

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  ./ 

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

  • 18
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 12
    评论
mmdetection中,有两种设置学习的方法。第一种方法是在训练命令后面添加参数--auto-scale-lr。这种方法会根据训练的规模自动调整学习。第二种方法则是根据使用的GPU数量和每个GPU的图像数量来设置学习。具体地,当使用8个GPU且每个GPU处理2个图像时,学习为0.02;当使用4个GPU且每个GPU处理2个图像时,学习为0.01;当使用2个GPU且每个GPU处理2个图像时,学习为0.005;当使用1个GPU且每个GPU处理2个图像时,学习为0.0025。 在训练过程中,还可以通过train.py的参数来调整学习。例如,--work-dir参数用于指定训练保存模型和日志的路径,--resume-from参数用于从预训练模型checkpoint中恢复训练,--no-validate参数用于在训练期间不评估checkpoint,--gpus参数用于指定训练使用的GPU数量,--gpu-ids参数用于指定使用哪一块GPU,--seed参数用于设置随机种子,--deterministic参数用于是否为CUDNN后端设置确定性选项,--options参数用于指定其他参数的字典,--launcher参数用于指定作业启动器,--local_rank参数用于指定LOCAL_RANK,--autoscale-lr参数用于根据测试数量自动缩放学习。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [MMDetection实战:MMDetection训练与测试](https://blog.csdn.net/hhhhhhhhhhwwwwwwwwww/article/details/124647370)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] - *2* [【mmdetectionmmdetection学习设置](https://blog.csdn.net/wxd1233/article/details/123128276)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

毕竟是shy哥

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

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

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

打赏作者

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

抵扣说明:

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

余额充值