ReDet网络复现

ReDet网络复现在DOTA数据集上

之前复现过一次,没有记录,再次调试时又遇到问题,总结一下问题。
ReDet: A Rotation-equivariant Detector for Aerial Object Detection
论文链接点击此处
源码链接点击此处
复现的环境是RTX3090

Installation

依据源码中的安装步骤,参考了这篇博客点击此处
源码中给出的requirements是:
Cython
numpy
mmcv == 0.2.13
shapely
tqdm
matplotlib
terminaltables
pycocotools
pillow == 6.2.2
e2cnn
我搭建后的环境是:
Python == 3.7.13
Pytorch == 1.8.1
CUDA == 11.1

Install ReDet

a. Create a conda virtual environment and activate it. Then install Cython.

创建ReDet的虚拟环境并安装Cython

conda create -n redet python=3.7 -y
source activate redet
conda install cython

b. Install PyTorch and torchvision following the official instructions.

安装PyToech和CUDA

pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

c. Clone the ReDet repository.

从GitHub上克隆源码并进入源码

git clone https://github.com/csuhan/ReDet.git
cd ReDet

d. Compile cuda extensions.

进行编译,由于AT_CHECK is deprecated in torch 1.5,高版本的pytorch不再使用AT_CHECK,而是使用 TORCH_CHECK,将所有待编译的源文件中的‘AT_CHECK’全部替换为‘TORCH_CHECK’,执行下面的程序

find . -type f -exec sed -i 's/AT_CHECK/TORCH_CHECK/g' {} +

执行之后,再进行编译

bash compile.sh

e. Install ReDet (other dependencies will be installed automatically).

安装相关包,安装失败的,可以自己用pip安装

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

Install DOTA_devkit

安装DOTA的处理工具

sudo apt-get install swig
cd DOTA_devkit
swig -c++ -python polyiou.i
python setup.py build_ext --inplace

Getting Started

将数据集放进data文件夹下,按照下列格式

data/dota15
├── train
│   ├──images
│   └──labelTxt
├── val
│   ├──images
│   └──labelTxt
└── test
    └──images

Split the original images and create COCO format json.

python DOTA_devkit/prepare_dota1_5.py --srcpath path_to_dota --dstpath path_to_split_1024

其中,–srcpath代表要分割图像的路径,–dstpath表示分割后图片的位置。
分割后会得到如下结构

dota15_1024
├── test1024
│   ├──DOTA_test1024.json
│   └──images
└── trainval1024
     ├──DOTA_trainval1024.json
     └──images

单GPU训练

python tools/train.py ${CONFIG_FILE}

多GPU训练

./tools/dist_train.sh ${CONFIG_FILE} ${GPU_NUM} [optional arguments]

测试

python tools/test.py configs/ReDet/ReDet_re50_refpn_1x_dota15.py work_dirs/ReDet_re50_refpn_1x_dota15/ReDet_re50_refpn_1x_dota15-7f2d6dda.pth --out work_dirs/ReDet_re50_refpn_1x_dota15/results.pkl

评估结果,产生坐标

python tools/parse_results.py --config configs/ReDet/ReDet_re50_refpn_1x_dota15.py --type OBB

合并图片,并将合并后的结果上传到 DOTA evaluation

在最新版的ReDet文件中缺少poly_nms_gpu,下载这个放到相应位置,然后执行make指令即可完成编译。

python DOTA_devkit/ResultMerge.py

你可能感兴趣的:(笔记,深度学习,pytorch)