必须用mmrotate才有hrsc的程序
1 安装环境:
Linux
RTX 3090
nvcc --version cuda 11.3
pytorch 1.11.0
conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=11.3 -c pytorch
测试pytorch是否安装成功:
>>> torch.__version__
'1.11.0'
>>> torch.cuda.get_device_name()
'GeForce RTX 3090'
然后利用mmlab 的引擎自动安装:
pip install -U openmim
mim install "mmengine==0.6.0"
mim install "mmcv==2.0.0rc4"
mim install "mmdet==3.0.0rc6"
因为我们要修改代码,所以不使用下边这句安装mmrotate
#mim install "mmrotate==1.0.0rc1"
要下载git仓库来安装:
git clone https://github.com/open-mmlab/mmrotate.git -b dev-1.x
# "-b dev-1.x" means checkout to the `dev-1.x` branch.
cd mmrotate
pip install -v -e .
# "-v" means verbose, or more output
# "-e" means installing a project in editable mode,
# thus any local modifications made to the code will take effect without reinstallation.
验证安装是否正确
为了验证MMRotate是否正确地被安装到了您的环境中,我们提供了一些demo以供测试。
第一步: 为了进行测试的验证,我们需要下载config文件与checkpoint文件。
mim download mmrotate --config oriented-rcnn-le90_r50_fpn_1x_dota --dest .
下载过程可能会依据您的网络状况花费数秒或者更多的时间。当下载完成之后,您可以在您的当前目录下找到 oriented-rcnn-le90_r50_fpn_1x_dota.py 和 oriented_rcnn_r50_fpn_1x_dota_le90-6d2b2ce0.pth 两个文件。
第二步: 使用推理demo完成验证
直接在命令行中运行以下代码即可:
python demo/image_demo.py demo/demo.jpg oriented-rcnn-le90_r50_fpn_1x_dota.py oriented_rcnn_r50_fpn_1x_dota_le90-6d2b2ce0.pth --out-file result.jpg
您将会在您的当前文件夹下看到一张 result.jpg 为文件名的图片,在该图片中完成了对于小轿车和公交车等物体的旋转锚定框的绘制。
至此,mmrotate已经成功安装完成。
2 测试hrsc2016数据集mAP
把HRSC2016放到
mmrotate-1.x/data/hrsc/FullDataSet
mmrotate-1.x/data/hrsc/ImageSets
mmrotate-1.x/data/hrsc/Test
mmrotate-1.x/data/hrsc/Train
先去网上下载模型,他论文中显示效果最好的是
rotated_rtmdet_tiny-9x-hrsc-9f2e3ca6.pth
我们下载好之后放到mmrotate-1.x的文件夹中
然后测试:
python tools/test.py configs/rotated_rtmdet/rotated_rtmdet_tiny-9x-hrsc.py rotated_rtmdet_tiny-9x-hrsc-9f2e3ca6.pth --work-dir work_dir/
最后输出:
05/05 13:01:03 - mmengine - INFO -
---------------iou_thr: 0.5---------------
05/05 13:01:05 - mmengine - INFO -
+-------+------+------+--------+-------+
| class | gts | dets | recall | ap |
+-------+------+------+--------+-------+
| ship | 1228 | 1913 | 0.980 | 0.906 |
+-------+------+------+--------+-------+
| mAP | | | | 0.906 |
+-------+------+------+--------+-------+
05/05 13:01:05 - mmengine - INFO -
---------------iou_thr: 0.5---------------
05/05 13:01:07 - mmengine - INFO -
+-------+------+------+--------+-------+
| class | gts | dets | recall | ap |
+-------+------+------+--------+-------+
| ship | 1228 | 1913 | 0.980 | 0.971 |
+-------+------+------+--------+-------+
| mAP | | | | 0.971 |
+-------+------+------+--------+-------+
05/05 13:01:07 - mmengine - INFO - Epoch(test) [453/453] dota_ap07/mAP: 0.9055 dota_ap07/AP50: 0.9060 dota_ap12/mAP: 0.9705 dota_ap12/AP50: 0.9710
3. 训练Hrsc2016数据集
python tools/train.py configs/rotated_rtmdet/rotated_rtmdet_tiny-9x-hrsc.py --work-dir work_dir/
我的 rtx 3090 大概需要30mins
05/05 13:55:53 - mmengine - INFO -
+-------+------+------+--------+-------+
| class | gts | dets | recall | ap |
+-------+------+------+--------+-------+
| ship | 1228 | 2374 | 0.979 | 0.902 |
+-------+------+------+--------+-------+
| mAP | | | | 0.902 |
+-------+------+------+--------+-------+
05/05 13:55:53 - mmengine - INFO -
---------------iou_thr: 0.5---------------
05/05 13:55:54 - mmengine - INFO -
+-------+------+------+--------+-------+
| class | gts | dets | recall | ap |
+-------+------+------+--------+-------+
| ship | 1228 | 2374 | 0.979 | 0.964 |
+-------+------+------+--------+-------+
| mAP | | | | 0.964 |
+-------+------+------+--------+-------+
05/05 13:55:54 - mmengine - INFO - Epoch(val) [36][453/453] dota_ap07/mAP: 0.9020 dota_ap07/AP50: 0.9020 dota_ap12/mAP: 0.9641 dota_ap12/AP50: 0.9640
并没有达到他的效果
我看它提示了训练了9x12epoch,我训练的是3x12epoch
我把 base_lr 改成 0.0025shishi