From d3f00294e3b0c67afe261c36e2ded07c93aec944 Mon Sep 17 00:00:00 2001 From: cnn Date: Thu, 5 Aug 2021 15:41:44 +0800 Subject: [PATCH] [dev] updata document and config (#3879) * updata document, test=document_fix * use 8 card for training as default, test=document_fix --- configs/dota/README.md | 31 +++++++------------ configs/dota/_base_/s2anet_optimizer_1x.yml | 2 +- configs/dota/_base_/s2anet_optimizer_2x.yml | 2 +- configs/dota/s2anet_1x_spine.yml | 4 +-- ...nv_1x_dota.yml => s2anet_conv_2x_dota.yml} | 11 ++----- 5 files changed, 18 insertions(+), 32 deletions(-) rename configs/dota/{s2anet_conv_1x_dota.yml => s2anet_conv_2x_dota.yml} (73%) diff --git a/configs/dota/README.md b/configs/dota/README.md index 809e7f8f0..f1512932f 100644 --- a/configs/dota/README.md +++ b/configs/dota/README.md @@ -9,7 +9,7 @@ ## 简介 -[S2ANet](https://arxiv.org/pdf/2008.09397.pdf)是用于检测旋转框的模型,要求使用PaddlePaddle 2.0.1(可使用pip安装) 或适当的[develop版本](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/install/Tables.html#whl-release)。 +[S2ANet](https://arxiv.org/pdf/2008.09397.pdf)是用于检测旋转框的模型,要求使用PaddlePaddle 2.1.1(可使用pip安装) 或适当的[develop版本](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/install/Tables.html#whl-release)。 ## 准备数据 @@ -53,11 +53,11 @@ DOTA数据集中总共有2806张图像,其中1411张图像作为训练集,45 - PaddlePaddle >= 2.1.1 - GCC == 8.2 -推荐使用docker镜像[paddle:2.0.1-gpu-cuda10.1-cudnn7](registry.baidubce.com/paddlepaddle/paddle:2.1.1-gpu-cuda10.2-cudnn7)。 +推荐使用docker镜像[paddle:2.1.1-gpu-cuda10.1-cudnn7](registry.baidubce.com/paddlepaddle/paddle:2.1.1-gpu-cuda10.1-cudnn7)。 执行如下命令下载镜像并启动容器: ``` -sudo nvidia-docker run -it --name paddle_s2anet -v $PWD:/paddle --network=host registry.baidubce.com/paddlepaddle/paddle:2.1.1-gpu-cuda10.2-cudnn7 /bin/bash +sudo nvidia-docker run -it --name paddle_s2anet -v $PWD:/paddle --network=host registry.baidubce.com/paddlepaddle/paddle:2.1.1-gpu-cuda10.1-cudnn7 /bin/bash ``` 镜像中paddle已安装好,进入python3.7,执行如下代码检查paddle安装是否正常: @@ -90,15 +90,7 @@ python3.7 test.py ### 2. 训练 **注意:** -配置文件中学习率是按照4卡GPU训练设置的,如果使用单卡GPU训练,请将学习率设置为原来的1/4。 - -准备数据 -```bash -cd dataset/spine_coco -wget https://paddledet.bj.bcebos.com/data/spine_coco.tar -tar -xvf spine_coco.tar -cd ../../ -``` +配置文件中学习率是按照8卡GPU训练设置的,如果使用单卡GPU训练,请将学习率设置为原来的1/8。 GPU单卡训练 ```bash @@ -108,25 +100,26 @@ python3.7 tools/train.py -c configs/dota/s2anet_1x_spine.yml GPU多卡训练 ```bash -export CUDA_VISIBLE_DEVICES=0,1,2,3 -python3.7 -m paddle.distributed.launch --gpus 0,1,2,3 tools/train.py -c configs/dota/s2anet_1x_spine.yml +export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 +python3.7 -m paddle.distributed.launch --gpus 0,1,2,3,4,5,6,7 tools/train.py -c configs/dota/s2anet_1x_spine.yml ``` 可以通过`--eval`开启边训练边测试。 -### 2. 评估 +### 3. 评估 ```bash python3.7 tools/eval.py -c configs/dota/s2anet_1x_spine.yml -o weights=output/s2anet_1x_spine/model_final.pdparams ``` +** 注意:** dota数据集中是train和val数据作为训练集一起训练的,对dota数据集进行评估时需要自定义设置评估数据集配置。 -### 3. 预测 -执行如下命令,会将图像预测结果保存到`output_dir`文件夹下。 +### 4. 预测 +执行如下命令,会将图像预测结果保存到`output`文件夹下。 ```bash python3.7 tools/infer.py -c configs/dota/s2anet_1x_spine.yml -o weights=output/s2anet_1x_spine/model_final.pdparams --infer_img=demo/39006.jpg ``` -### 4. DOTA数据评估 -执行如下命令,会在`output_dir`文件夹下将每个图像预测结果保存到同文件夹名的txt文本中。 +### 5. DOTA数据评估 +执行如下命令,会在`output`文件夹下将每个图像预测结果保存到同文件夹名的txt文本中。 ``` python3.7 tools/infer.py -c configs/dota/s2anet_1x_dota.yml -o weights=./weights/s2anet_1x_dota.pdparams --infer_dir=dota_test_images --draw_threshold=0.05 --save_txt=True --output_dir=output ``` diff --git a/configs/dota/_base_/s2anet_optimizer_1x.yml b/configs/dota/_base_/s2anet_optimizer_1x.yml index 91069a3bb..65f794dc3 100644 --- a/configs/dota/_base_/s2anet_optimizer_1x.yml +++ b/configs/dota/_base_/s2anet_optimizer_1x.yml @@ -1,7 +1,7 @@ epoch: 12 LearningRate: - base_lr: 0.005 + base_lr: 0.01 schedulers: - !PiecewiseDecay gamma: 0.1 diff --git a/configs/dota/_base_/s2anet_optimizer_2x.yml b/configs/dota/_base_/s2anet_optimizer_2x.yml index c96027a61..54e73ce64 100644 --- a/configs/dota/_base_/s2anet_optimizer_2x.yml +++ b/configs/dota/_base_/s2anet_optimizer_2x.yml @@ -1,7 +1,7 @@ epoch: 24 LearningRate: - base_lr: 0.005 + base_lr: 0.01 schedulers: - !PiecewiseDecay gamma: 0.1 diff --git a/configs/dota/s2anet_1x_spine.yml b/configs/dota/s2anet_1x_spine.yml index 440ac143a..5cf215b54 100644 --- a/configs/dota/s2anet_1x_spine.yml +++ b/configs/dota/s2anet_1x_spine.yml @@ -8,9 +8,9 @@ _BASE_: [ weights: output/s2anet_1x_spine/model_final -# for 4 card +# for 8 card LearningRate: - base_lr: 0.005 + base_lr: 0.01 S2ANetHead: anchor_strides: [8, 16, 32, 64, 128] diff --git a/configs/dota/s2anet_conv_1x_dota.yml b/configs/dota/s2anet_conv_2x_dota.yml similarity index 73% rename from configs/dota/s2anet_conv_1x_dota.yml rename to configs/dota/s2anet_conv_2x_dota.yml index a81c76f3f..3d95c566e 100644 --- a/configs/dota/s2anet_conv_1x_dota.yml +++ b/configs/dota/s2anet_conv_2x_dota.yml @@ -1,18 +1,11 @@ _BASE_: [ '../datasets/dota.yml', '../runtime.yml', - '_base_/s2anet_optimizer_1x.yml', + '_base_/s2anet_optimizer_2x.yml', '_base_/s2anet.yml', '_base_/s2anet_reader.yml', ] -weights: output/s2anet_1x_dota/model_final - -ResNet: - depth: 50 - variant: b - norm_type: bn - return_idx: [1,2,3] - num_stages: 4 +weights: output/s2anet_conv_1x_dota/model_final S2ANetHead: anchor_strides: [8, 16, 32, 64, 128] -- GitLab