oriented_rcnn的安装

前前后后搞了快一周,终于弄好了,所以记录一下
一.安装环境

服务器的cuda版本为11.7,故安装的pytorch的cuda应该小于等于11.7,一般而言选择3.8版本的python,该版本比较稳定。

#以3.8.5的python为基础,安装pytorch等基本包
conda create -n OBB python=3.8.5 -y
conda activate OBB
pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html
​
#安装BboxToolkit
cd BboxToolkit
pip install -v -e .
cd .. #转到OBBDetection
​
#安装mmcv
pip install -U openmim #安装mmcv的下载器,相当于pip
mim install mmcv-full==1.4.1
​
#安装依赖mmcv的mmdetection的mmdet(作者实在mmdetection上进行改进的,主要安装里面的mmdet)
pip install -r requirements/build.txt
pip install pycocotools
pip install cython==0.29.33 #如果没有这段代码,mmpycocotools可能安装失败
pip install mmpycocotools #mmdetection的mmdet的依赖包
pip install -v -e . #安装mmdetection的mmdet
二.运行demo

OBBDetection/configs/obb/oriented_rcnn at master · jbwang1997/OBBDetection · GitHub中下载对应的训练模型

img

然后运行代码

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_dota10_epoch12.pth BboxToolkit/tools/split_configs/dota1_0/ss_test.json
#configs那段是模型;ckpt是预训练模型的参数,可以改名字

最后会出来结果图

img

三.用HRSC2016进行训练与预测

首先将数据集放在该目录下(OBBDetection)的data下,路径需要与configs/obb/base/datasets/hrsc的data_root一致;然后运行代码

python tools/train.py configs/obb/oriented_rcnn/new_faster_rcnn_orpn_r101_fpn_3x_hrsc.py --work-dir work_dirs #最后一项是存储模型等的位置,可以改名字

最后将work_dirs的最后一个模型参数用于预测,代码如下

python tools/test.py configs/obb/oriented_rcnn/faster_rcnn_orpn_r101_fpn_3x_hrsc.py work_dirs/epoch_36.pth --eval mAP --options use_07_metric=False

可以得到下图所示

四.用DOTAV1进行模型的训练与预测

训练模型前需要将图片进行分割,代码中有现成的模块,在BboxToolkit里,需要将数据集放入BboxToolkit/tools/data,同时改变split_configs/dota1_0/ss_dota_train.json里的路径,如这段话所示 (modify the img_dirs, ann_dirs and save_dir in split_configs/dota1_0/ss_train.json)

cd BboxToolkit/tools/
# modify the img_dirs, ann_dirs and save_dir in split_configs/dota1_0/ss_train.json
python img_split.py --base_json split_configs/dota1_0/ss_train.json

分割完成后得到数据集,在BboxToolkit/tools/data/split_ss_dota1_0

将其放入到data/中,接着使用代码

python tools/train.py configs/obb/oriented_rcnn/faster_rcnn_orpn_r50_fpn_1x_dota10.py  --work-dir work_dirs  #训练
python tools/test.py configs/obb/oriented_rcnn/faster_rcnn_orpn_r50_fpn_3x_hrsc.py /root/OBBDetection/work_dirs/epoch_36.pth --eval mAP #测试

五.其他问题

中途遇到了numpy的版本问题,一般而言不能降版本,只能将np.int换为np.int64这种。

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值