环境:windows10+ cundn10.1+ cudnn7.6+ vs2019+pythorch1.4或windows10+ cundn10.2+ cudnn7.6 +vs2019+pythorch1.5
MMdetection2.0已于5.6发布:https://github.com/open-mmlab/mmdetection;这样其性能应该高于detectron2的性能(有待后续测试)
1、编译问题记录
需下载coco的pythonAPI
安装MMdetection项目依赖库  pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple  用清华源安装会比较快

2、faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth官方模型测试(模型下载https://github.com/open-mmlab/mmdetection/tree/master/configs/faster_rcnn
python demo/image_demo.py demo/demo.jpg configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py checkpoints/faster_rcnn/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth 

视频测试:python demo/webcam_demo.py configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py checkpoints/faster_rcnn/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth

3、faster_rcnn_r50_fpn_1x_coco训练自己的数据
a)数据集制作:
国内交通标志数据集:共包含1465张640*640的交通标志图片,一共标注了6类交通标志,分别是:直行、左转、右转、禁行、禁鸣、人行横道,("straight", "left","right", "stop ", "nohonk", "crosswalk")。标注信息均保存在xml文件下载地址:https://www.kesci.com/home/dataset/5ea92354366f4d002d730fca 转换为coco2017即可;具体参考detectron2中制作方法

b)修改MMdetection2.0的配置文件用于训练数据
查看./configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py中查看需要配置或修改的四个文件 为需要的分类个数,共有两处

修改./configs/_base_/models/faster_rcnn_r50_fpn.py中的为需要的分类个数

查看修改./configs/_base_/schedules/schedule_1x.py中的lr和迭代次数等
查看修改./configs/_base_/datasets/coco_detection.py中的训练数据加载路径修改

修改./mmdet/datasets/coco.py中的Classname为自己的数据集

之后训练即可:python tools/train.py configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py

测试结果图:python demo/image_demo.py demo/sign_4.jpg configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py work_dirs/faster_rcnn_r50_fpn_1x_coco/epoch_100.pth

 

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐