在mmdetection中跑通MaskRCNN

时间:2023-03-09 02:35:19
在mmdetection中跑通MaskRCNN

1、将数据集转化成COCO格式数据集

Kaggle->COCO:

https://github.com/pascal1129/kaggle_airbus_ship_detection/blob/master/0_rle_to_coco/1_ships_to_coco.py

2、修改匹配的训练参数文件

/xxx/mmdetection/configs/mask_rcnn_r50_fpn_1x.py

40行左右的num_classes值为实际分类数+1(背景类)
102行左右的data_root值为数据集的根路径
train、val、test的ann_file、img_prefix、img_scale 中继训练时修改163行的load_from和164行的resume_from为'/xxx/xxx/epoch_xxx.pth'

3、训练脚本

CUDA_VISIBLE_DEVICES=0,1,2,3 python /xxx/mmdetection/tools/train.py config /xxx/mmdetection/configs/mask_rcnn_r50_fpn_1x.py --work_dir ./work_dirs/mask_rcnn_r50_fpn_1x --validate --gpus 3

#0,1,2,3是4张显卡全部可用的意思,具体调用几张,看最后面的--gpus 3

4、测试脚本

CUDA_VISIBLE_DEVICES=1,2,3 python /xxx/mmdetection/tools/test.py config /xxx/mmdetection/configs/mask_rcnn_r50_fpn_1x.py --checkpoint ./work_dirs/mask_rcnn_r50_fpn_1x/epoch_xxx.pth --out /xxx/workspace/out/maskrcnn.pkl --eval segm --gpus 3

5、图像的形式显示结果

https://github.com/open-mmlab/mmdetection/issues/92#issuecomment-438193334