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