数据增强
模型集成
训练采样
模型部分
误差分析:从rpn很难收敛及OHEM掉分严重可以分析得出目前预测错误主要来源是:
OS: Ubuntu16.10
GPU: 2080Ti * 4
python: python3.7
nvidia 依赖:
deeplearning 框架: pytorch1.1.0
其他依赖请参考requirement.txt
显卡数量不太重要,大家依据自身显卡数量倍数调整学习率大小即可
相应文件夹创建准备
在代码根目录下新建data文件夹,或者依据自身情况建立软链接
进入data文件夹,创建文件夹:
annotations
pretrained
results
submit
将官方提供的训练和测试数据解压到data目录中,产生:
train
test-A-image
label文件格式转换
官方提供的是VOC格式的xml类型label文件,个人习惯使用COCO格式用于训练,所以进行格式转换
使用 tools/data_process/xml2coco.py 将label文件转换为COCO格式,新的label文件 train.json 会保存在 data/train/annotations 目录下
为了方便利用mmd多进程测试(速度较快),我们对test数据也生成一个伪标签文件,运行 tools/data_process/generate_test_json.py 生成 testA.json, 伪标签文件会保存在data/train/annotations 目录下
总体运行内容:
python tools/data_process/xml2coco.py
python tools/data_process/generate_test_json.py
预训练模型下载
依赖安装编译
创建并激活虚拟环境 conda create -n underwater python=3.7 -y conda activate underwater
安装 pytorch conda install pytorch=1.1.0 torchvision=0.3.0 cudatoolkit=10.0 -c pytorch
安装其他依赖 pip install cython && pip --no-cache-dir install -r requirements.txt
编译cuda op等: python setup.py develop
训练
运行:
r50:
chmod +x tools/dist_train.sh
./tools/dist_train.sh configs/underwater/cas_r50/cascade_rcnn_r50_fpn_1x.py 4
se50:
chmod +x tools/dist_train.sh
./tools/dist_train.sh configs/underwater/cas_se/cas_se50_12ep.py 4
x101_64x4d (htc pretrained):
chmod +x tools/dist_train.sh
./tools/dist_train.sh configs/underwater/cas_x101/cascade_rcnn_x101_64x4d_fpn_1x.py 4
(上面的4是我的gpu数量,请自行修改)
训练过程文件及最终权重文件均保存在config文件中指定的workdir目录中
预测
运行:
r50:
chmod +x tools/dist_test.sh
./tools/dist_test.sh configs/underwater/cas_r50/cascade_rcnn_r50_fpn_1x.py workdirs/cascade_rcnn_r50_fpn_1x/latest.pth 4 --json_out results/cas_r50.json
(上面的4是我的gpu数量,请自行修改)
se50:
chmod +x tools/dist_test.sh
./tools/dist_test.sh configs/underwater/cas_se/cas_se50_12ep.py workdirs/cas_se50_12ep/latest.pth 4 --json_out results/cas_se50.json
(上面的4是我的gpu数量,请自行修改)
x101_64x4d (htc pretrained):
chmod +x tools/dist_test.sh
./tools/dist_test.sh configs/underwater/cas_x101/cascade_rcnn_x101_64x4d_fpn_1x.py workdirs/cas_x101_64x4d_fpn_htc_1x/latest.pth 4 --json_out results/cas_x101.json
预测结果文件会保存在 /results 目录下
转化mmd预测结果为提交csv格式文件:
python tools/post_process/json2submit.py --test_json cas_r50.bbox.json --submit_file cas_r50.csv
python tools/post_process/json2submit.py --test_json cas_se50.bbox.json --submit_file cas_se50.csv
python tools/post_process/json2submit.py --test_json cas_x101.bbox.json --submit_file cas_x101.csv
最终符合官方要求格式的提交文件 cas_r50.csv, cas_se50.csv 和 cas_x101.csv 位于 submit目录下
author:rill
email:18813124313@163.com