ReDet网络复现

本文档详细记录了在RTX3090显卡环境下,复现ReDet网络(一种旋转等变目标检测器)在DOTA数据集上的过程。首先创建并激活Python3.7的虚拟环境,安装必要的依赖库如PyTorch 1.8.1和CUDA 11.1。接着,克隆ReDet项目并修改源码以适配高版本PyTorch,编译CUDA扩展。之后,安装DOTA_devkit并准备数据集,将其转换为COCO格式。最后,说明了单GPU和多GPU训练的命令,以及测试和评估的步骤。在运行过程中需要注意的是,如果遇到编译问题,需要手动处理并编译poly_nms_gpu模块。
部署运行你感兴趣的模型镜像

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 2.5

PyTorch 2.5

PyTorch
Cuda

PyTorch 是一个开源的 Python 机器学习库,基于 Torch 库,底层由 C++ 实现,应用于人工智能领域,如计算机视觉和自然语言处理

评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值