复现Oriented R-CNN for Object Detection(orientedRcnn)

1. Environment configuration

1. Create a python 3.7 environment

conda create -n obbdetection python=3.7 -y #虚拟环境命令
mkvirtualenv –p python3.7 name #virtualenv创建命令

2. Install torch1.6.0 cuda as 10.2
3. Install BboxToolkit

cd BboxToolkit
pip install -v -e .  # or "python setup.py develop"
cd ..

 4. Install mmcv=1.4.0

 pip install mmcv-full==1.4.0 -f https://download.openmmlab.com/mmcv/dist/cu102/torch1.6.0/index.html --no-cache-dir

5. Install OBB Detection

pip install -r requirements/build.txt
pip install mmpycocotools
pip install -v -e .  # or "python setup.py develop"

6. Install timm 0.6.5

pip install timm==0.6.5

Second, the parameters that need to be modified

1. Change the pretrained path under the called configs file to the path of the pre-trained weights you downloaded
2. Change the hrsc.py file called under the configs file, ① the path of data_root is the path of your HRSC2016 dataset, ② training and Paths of imgset, ann_file, and img_prefix for testing
3. Change the schedule.py file called under the configs file, and change some parameters according to your needs
4. Change the default_runtime.py file called under the configs file, and change some parameters according to your needs

3. Visualization of the trained weight test 

1.huge_image_demo.py

python demo/huge_image_demo.py demo/dota_demo.jpg configs/obb/oriented_rcnn/faster_rcnn_orpn_r101_fpn_1x_ms_rr_dota10.py	 ckpt/faster_rcnn_orpn_r101_fpn_1x_mssplit_rr_dota10_epoch12.pth BboxToolkit/tools/split_configs/dota1_0/ss_test.json

2.image_demo.py

python demo/image_demo.py demo/dota_demo.jpg configs/obb/oriented_rcnn/faster_rcnn_orpn_r101_fpn_1x_ms_rr_dota10.py	 ckpt/faster_rcnn_orpn_r101_fpn_1x_mssplit_rr_dota10_epoch12.pth

The difference between the two commands is the difference in the py file. 2 has less BboxToolkit than 1, and 1 uses BboxToolkit to test visualization in batches.

The difference between the config file
1.ms means multi-scale image segmentation, and rr means random rotation.
rr: dict(type='RandomOBBRotate', rotate_after_flip=True,
         angles=(0, 90), vert_rate=0.5, vert_cls=['roundabout', 'storage-tank']),
ms should be directly reflected in the split dataset on

4. Training command

1. Training HRSC2016 dataset command

The configs file of the hrsc dataset corresponding to python tools/train.py --work-dir work_dirs (work log and path to save weights)
For example:

python tools/train.py configs/obb/oriented_rcnn/faster_rcnn_orpn_r50_fpn_3x_hrsc.py --work-dir work_dirs

Part of the parameter description that may be used: ①--gpus The number of gpus to be used ②--gpu-ids The id of the gpus to be used.

2. Training DOTA dataset command

The DOTA data set needs to use the BboxToolkit toolkit to divide the data set and convert the format of the annotation file. Unlike the HRSC2016 data set, it is easy to train directly, so an additional chapter is written about the training method of the DOTA data set.

5. Test accuracy

1. Test HRSC2016 dataset VOC 07 and 12 accuracy

The test command is as follows:

python tools/test.py configs/obb/oriented_rcnn/faster_rcnn_orpn_r50_fpn_3x_hrsc.py work_dirs/HRSC2016_1/epoch_31.pth --eval mAP

Some parameters that may be used: ①--out output file in pickle format ②--eval evaluation metrics, which depends on the dataset, eg, bbox, segm, proposal for coco, and map, recall for pascal voc ③-- show-dir directory to save drawn images

2. Test the DOTA dataset

The DOTA data set needs to use the BboxToolkit toolkit to divide the data set and convert the format of the annotation file. Unlike the HRSC2016 data set, it is easy to test directly, so an additional chapter is written about the testing method of the DOTA data set.

6. Verification

python demo/image_demo.py demo/100001132.bmp configs/obb/oriented_rcnn/faster_rcnn_orpn_r101_fpn_3x_hrsc.py  work_dirs/epoch_36.pth  

 

 Effect picture after training

problems encountered

1. pip install mmpycocotools Install mmpycocotools error: error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Solution: Check your python version, and then download your own version of Python devel, such as python3.7.7 is: sudo apt-get install python3.7-dev

Guess you like

Origin blog.csdn.net/weixin_42715977/article/details/130924006