mmdetection训练coco数据集(继跑通后的一些工具使用)

(仅做个人过程记录的笔记)

1、生成中间件

可以选择评估方式 --eval ,对于 COCO 数据集,可选 bbox 、segmproposal 。可以得到result.bbox.json文件

生成pkl文件:faster_rcnn.pkl

python tools/test.py config.py work_dirs/epoch_20.pth  --out faster_rcnn.pkl

后续可以直接使用他来做分析,无需每次都从头测试。 如下:

python config.py faster_rcnn.pkl --eval bbox

得到结果如下:

mmdetection训练coco数据集(继跑通后的一些工具使用)_第1张图片

2、tools里部分的工具使用

  • coco_error_analysis.py 获得COCO bbox错误结果每个类别,保存分析结果图像到目录results/
python tools/analysis_tools/coco_error_analysis.py results.bbox.json results  --ann=data/coco/annotations/instances_val2017.json

结果如下:

mmdetection训练coco数据集(继跑通后的一些工具使用)_第2张图片

  • analyze_results.py  将模型的预测结果框画出来进行可视化
python tools/analysis_tools/analyze_results.py configs.py faster_rcnn.pkl show_dir/

结果如下:

由于目标太小,报错了。[WinError 1455] 页面文件太小,无法完成操作。

  • analyze_logs.py 分析我们训练过程中得到的日志文件的每次epoch训练结果

先pip install seaborn

python tools/analysis_tools/analyze_logs.py plot_curve  tools\work_dirs\faster_rcnn_r101_fpn_1x_coco\20230530_182545.log.json --out log_curve.png
  • confusion_matrix.py  生成混淆矩阵

python tools/analysis_tools/confusion_matrix.py configs.py tools\work_dirs\faster_rcnn_r101_fpn_1x_coco\fasterrcnn.pkl results/coco_confusion_matrix/

结果如下: mmdetection训练coco数据集(继跑通后的一些工具使用)_第3张图片

3、多类目标训练查看单类准确率(AP)

test.py 后面加--options "classwise=True" 即可

python tools/test.py configs/A_traintest/faster_rcnn_r101_fpn_1x_coco_3channel.py work_dirs/faster_rcnn_r101_fpn_1x_coco/epoch_13.pth --options "classwise=True"  --eval bbox

结果如下:mmdetection训练coco数据集(继跑通后的一些工具使用)_第4张图片

只想显示 0.5时精度 在mmdetection/mmdet/datasets/coco.py的def evaluate()中:classwise=False为classwise=True,iou_thrs=[0.5]即可

即:def evaluate(self,
                 results,
                 metric='bbox',
                 logger=None,
                 jsonfile_prefix=None,
                 classwise=False,
                 proposal_nums=(100, 300, 1000),
                 iou_thrs=[0.5],
                 metric_items=None):

参考博主文章:

mmdetection tools工具梳理_bbox_map_copypaste_Adenialzz的博客-CSDN博客

【mmdetecion】mmdetection多类目标训练查看单类准确率(AP)_mmdet测试正确率_gorgeous(๑>؂<๑)的博客-CSDN博客

你可能感兴趣的:(python,开发语言)