From 2348dcded813412879dcfedac202d2b1210840a8 Mon Sep 17 00:00:00 2001 From: Wenyu Date: Tue, 2 Nov 2021 00:51:16 +0800 Subject: [PATCH] update sniper docs (#4411) --- configs/sniper/README.md | 14 ++++---- configs/sniper/README_cn.md | 14 ++++---- ...faster_rcnn_r50_fpn_1x_sniper_visdrone.yml | 22 ++++++++++++- .../faster_rcnn_r50_fpn_1x_visdrone.yml | 2 +- .../faster_rcnn_r50_fpn_2x_sniper_coco.yml | 15 --------- .../faster_rcnn_r50_vd_1x_coco_sniper.yml | 19 ----------- .../faster_rcnn_r50_vd_fpn_2x_sniper_coco.yml | 25 --------------- configs/sniper/ppyolo_r50vd_dcn_1x_sniper.yml | 32 ------------------- .../ppyolo_r50vd_dcn_1x_sniper_visdrone.yml | 25 ++++++++++++++- .../ppyolo_r50vd_dcn_1x_visdrone.yml | 4 +-- 10 files changed, 62 insertions(+), 110 deletions(-) rename configs/{faster_rcnn => sniper}/faster_rcnn_r50_fpn_1x_visdrone.yml (89%) delete mode 100644 configs/sniper/faster_rcnn_r50_fpn_2x_sniper_coco.yml delete mode 100644 configs/sniper/faster_rcnn_r50_vd_1x_coco_sniper.yml delete mode 100644 configs/sniper/faster_rcnn_r50_vd_fpn_2x_sniper_coco.yml delete mode 100644 configs/sniper/ppyolo_r50vd_dcn_1x_sniper.yml rename configs/{ppyolo => sniper}/ppyolo_r50vd_dcn_1x_visdrone.yml (90%) diff --git a/configs/sniper/README.md b/configs/sniper/README.md index 112503373..27cf16f13 100644 --- a/configs/sniper/README.md +++ b/configs/sniper/README.md @@ -6,8 +6,8 @@ English | [简体中文](README_cn.md) | Sniper | GPU number | images/GPU | Model | Dataset | Schedulers | Box AP | Download | Config | | :---------------- | :-------------------: | :------------------: | :-----: | :-----: | :------------: | :-----: | :-----------------------------------------------------: | :-----: | -| w/o | 4 | 1 | ResNet-r50-FPN | [VisDrone](https://github.com/VisDrone/VisDrone-Dataset) | 1x | 23.3 | [Download Link](https://bj.bcebos.com/v1/paddledet/models/faster_rcnn_r50_fpn_1x_visdrone.pdparams ) | [Config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/sniper/faster_rcnn_r50_fpn_1x_sniper_coco.yml) | -| w/ | 4 | 1 | ResNet-r50-FPN | [VisDrone](https://github.com/VisDrone/VisDrone-Dataset) | 1x | 29.7 | [Download Link](https://bj.bcebos.com/v1/paddledet/models/faster_rcnn_r50_fpn_1x_sniper_visdrone.pdparams) | [Config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/sniper/faster_rcnn_r50_fpn_2x_sniper_coco.yml) | +| w/o | 4 | 1 | ResNet-r50-FPN | [VisDrone](https://github.com/VisDrone/VisDrone-Dataset) | 1x | 23.3 | [Download Link](https://bj.bcebos.com/v1/paddledet/models/faster_rcnn_r50_fpn_1x_visdrone.pdparams ) | [config](./faster_rcnn_r50_fpn_1x_visdrone.yml) | +| w/ | 4 | 1 | ResNet-r50-FPN | [VisDrone](https://github.com/VisDrone/VisDrone-Dataset) | 1x | 29.7 | [Download Link](https://bj.bcebos.com/v1/paddledet/models/faster_rcnn_r50_fpn_1x_sniper_visdrone.pdparams) | [config](./faster_rcnn_r50_fpn_1x_sniper_visdrone.yml) | ### Note > Here, we use VisDrone dataset, and to detect 9 objects including `person, bicycles, car, van, truck, tricyle, awning-tricyle, bus, motor`. @@ -21,18 +21,18 @@ python tools/sniper_params_stats.py FasterRCNN annotations/instances_train2017.j ``` b. optional: trian detector to get negative proposals. ```bash -python -m paddle.distributed.launch --log_dir=./sniper/ --gpus 0,1,2,3,4,5,6,7 tools/train.py -c configs/sniper/faster_rcnn_r50_fpn_2x_sniper_coco.yml --save_proposals --proposals_path=./proposals.json &>sniper.log 2>&1 & +python -m paddle.distributed.launch --log_dir=./sniper/ --gpus 0,1,2,3,4,5,6,7 tools/train.py -c configs/sniper/faster_rcnn_r50_fpn_1x_sniper_visdrone.yml --save_proposals --proposals_path=./proposals.json &>sniper.log 2>&1 & ``` c. train models ```bash -python -m paddle.distributed.launch --log_dir=./sniper/ --gpus 0,1,2,3,4,5,6,7 tools/train.py -c configs/sniper/faster_rcnn_r50_fpn_2x_sniper_coco.yml --eval &>sniper.log 2>&1 & +python -m paddle.distributed.launch --log_dir=./sniper/ --gpus 0,1,2,3,4,5,6,7 tools/train.py -c configs/sniper/faster_rcnn_r50_fpn_1x_sniper_visdrone.yml --eval &>sniper.log 2>&1 & ``` ### 2. Evaluation Evaluating SNIPER on custom dataset in single GPU with following commands: ```bash # use saved checkpoint in training -CUDA_VISIBLE_DEVICES=0 python tools/eval.py -c configs/sniper/faster_rcnn_r50_fpn_2x_sniper_coco.yml -o weights=output/faster_rcnn_r50_fpn_2x_sniper_coco/model_final +CUDA_VISIBLE_DEVICES=0 python tools/eval.py -c configs/sniper/faster_rcnn_r50_fpn_1x_sniper_visdrone.yml -o weights=output/faster_rcnn_r50_fpn_1x_sniper_visdrone/model_final ``` ### 3. Inference @@ -40,10 +40,10 @@ Inference images in single GPU with following commands, use `--infer_img` to inf ```bash # inference single image -CUDA_VISIBLE_DEVICES=0 python tools/infer.py -c configs/sniper/faster_rcnn_r50_fpn_2x_sniper_coco.yml -o weights=output/faster_rcnn_r50_fpn_2x_sniper_coco/model_final --infer_img=demo/P0861__1.0__1154___824.png +CUDA_VISIBLE_DEVICES=0 python tools/infer.py -c configs/sniper/faster_rcnn_r50_fpn_1x_sniper_visdrone.yml -o weights=output/faster_rcnn_r50_fpn_1x_sniper_visdrone/model_final --infer_img=demo/P0861__1.0__1154___824.png # inference all images in the directory -CUDA_VISIBLE_DEVICES=0 python tools/infer.py -c configs/sniper/faster_rcnn_r50_fpn_2x_sniper_coco.yml -o weights=output/faster_rcnn_r50_fpn_2x_sniper_coco/model_final --infer_dir=demo +CUDA_VISIBLE_DEVICES=0 python tools/infer.py -c configs/sniper/faster_rcnn_r50_fpn_1x_sniper_visdrone.yml -o weights=output/faster_rcnn_r50_fpn_1x_sniper_visdrone/model_final --infer_dir=demo ``` ## Citations diff --git a/configs/sniper/README_cn.md b/configs/sniper/README_cn.md index 13e2e49a8..ed96600a5 100644 --- a/configs/sniper/README_cn.md +++ b/configs/sniper/README_cn.md @@ -5,8 +5,8 @@ ## 模型库 | 有无sniper | GPU个数 | 每张GPU图片个数 | 骨架网络 | 数据集 | 学习率策略 | Box AP | 模型下载 | 配置文件 | | :---------------- | :-------------------: | :------------------: | :-----: | :-----: | :------------: | :-----: | :-----------------------------------------------------: | :-----: | -| w/o sniper | 4 | 1 | ResNet-r50-FPN | [VisDrone](https://github.com/VisDrone/VisDrone-Dataset) | 1x | 23.3 | [下载链接](https://bj.bcebos.com/v1/paddledet/models/faster_rcnn_r50_fpn_1x_visdrone.pdparams ) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/sniper/faster_rcnn_r50_fpn_1x_sniper_coco.yml) | -| w sniper | 4 | 1 | ResNet-r50-FPN | [VisDrone](https://github.com/VisDrone/VisDrone-Dataset) | 1x | 29.7 | [下载链接](https://bj.bcebos.com/v1/paddledet/models/faster_rcnn_r50_fpn_1x_sniper_visdrone.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/sniper/faster_rcnn_r50_fpn_2x_sniper_coco.yml) | +| w/o sniper | 4 | 1 | ResNet-r50-FPN | [VisDrone](https://github.com/VisDrone/VisDrone-Dataset) | 1x | 23.3 | [下载链接](https://bj.bcebos.com/v1/paddledet/models/faster_rcnn_r50_fpn_1x_visdrone.pdparams ) | [配置文件](./faster_rcnn_r50_fpn_1x_visdrone.yml) | +| w sniper | 4 | 1 | ResNet-r50-FPN | [VisDrone](https://github.com/VisDrone/VisDrone-Dataset) | 1x | 29.7 | [下载链接](https://bj.bcebos.com/v1/paddledet/models/faster_rcnn_r50_fpn_1x_sniper_visdrone.pdparams) | [配置文件](./faster_rcnn_r50_fpn_1x_sniper_visdrone.yml) | ### 注意 @@ -21,18 +21,18 @@ python tools/sniper_params_stats.py FasterRCNN annotations/instances_train2017.j ``` b. 可选:训练检测器,生成负样本 ```bash -python -m paddle.distributed.launch --log_dir=./sniper/ --gpus 0,1,2,3,4,5,6,7 tools/train.py -c configs/sniper/faster_rcnn_r50_fpn_2x_sniper_coco.yml --save_proposals --proposals_path=./proposals.json &>sniper.log 2>&1 & +python -m paddle.distributed.launch --log_dir=./sniper/ --gpus 0,1,2,3,4,5,6,7 tools/train.py -c configs/sniper/faster_rcnn_r50_fpn_1x_sniper_visdrone.yml --save_proposals --proposals_path=./proposals.json &>sniper.log 2>&1 & ``` c. 训练模型 ```bash -python -m paddle.distributed.launch --log_dir=./sniper/ --gpus 0,1,2,3,4,5,6,7 tools/train.py -c configs/sniper/faster_rcnn_r50_fpn_2x_sniper_coco.yml --eval &>sniper.log 2>&1 & +python -m paddle.distributed.launch --log_dir=./sniper/ --gpus 0,1,2,3,4,5,6,7 tools/train.py -c configs/sniper/faster_rcnn_r50_fpn_1x_sniper_visdrone.yml --eval &>sniper.log 2>&1 & ``` ### 2. 评估 使用单GPU通过如下命令一键式评估模型在COCO val2017数据集效果 ```bash # 使用训练保存的checkpoint -CUDA_VISIBLE_DEVICES=0 python tools/eval.py -c configs/sniper/faster_rcnn_r50_fpn_2x_sniper_coco.yml -o weights=output/faster_rcnn_r50_fpn_2x_sniper_coco/model_final +CUDA_VISIBLE_DEVICES=0 python tools/eval.py -c configs/sniper/faster_rcnn_r50_fpn_1x_sniper_visdrone.yml -o weights=output/faster_rcnn_r50_fpn_1x_sniper_visdrone/model_final ``` ### 3. 推理 @@ -40,10 +40,10 @@ CUDA_VISIBLE_DEVICES=0 python tools/eval.py -c configs/sniper/faster_rcnn_r50_fp ```bash # 推理单张图像 -CUDA_VISIBLE_DEVICES=0 python tools/infer.py -c configs/sniper/faster_rcnn_r50_fpn_2x_sniper_coco.yml -o weights=output/faster_rcnn_r50_fpn_2x_sniper_coco/model_final --infer_img=demo/P0861__1.0__1154___824.png +CUDA_VISIBLE_DEVICES=0 python tools/infer.py -c configs/sniper/faster_rcnn_r50_fpn_1x_sniper_visdrone.yml -o weights=output/faster_rcnn_r50_fpn_1x_sniper_visdrone/model_final --infer_img=demo/P0861__1.0__1154___824.png # 推理目录下所有图像 -CUDA_VISIBLE_DEVICES=0 python tools/infer.py -c configs/sniper/faster_rcnn_r50_fpn_2x_sniper_coco.yml -o weights=output/faster_rcnn_r50_fpn_2x_sniper_coco/model_final --infer_dir=demo +CUDA_VISIBLE_DEVICES=0 python tools/infer.py -c configs/sniper/faster_rcnn_r50_fpn_1x_sniper_visdrone.yml -o weights=output/faster_rcnn_r50_fpn_1x_sniper_visdrone/model_final --infer_dir=demo ``` ## Citations diff --git a/configs/sniper/faster_rcnn_r50_fpn_1x_sniper_visdrone.yml b/configs/sniper/faster_rcnn_r50_fpn_1x_sniper_visdrone.yml index aaf22e126..1b43e4049 100644 --- a/configs/sniper/faster_rcnn_r50_fpn_1x_sniper_visdrone.yml +++ b/configs/sniper/faster_rcnn_r50_fpn_1x_sniper_visdrone.yml @@ -5,7 +5,27 @@ _BASE_: [ '../faster_rcnn/_base_/optimizer_1x.yml', '_base_/faster_fpn_reader.yml', ] -weights: output/faster_rcnn_r50_1x_visdrone_coco/model_final +weights: output/faster_rcnn_r50_fpn_1x_sniper_visdrone/model_final find_unused_parameters: true + +metric: COCO +num_classes: 9 + +TrainDataset: + !COCODataSet + image_dir: train + anno_path: annotations/train.json + dataset_dir: dataset/VisDrone2019_coco + data_fields: ['image', 'gt_bbox', 'gt_class', 'is_crowd'] + +EvalDataset: + !COCODataSet + image_dir: val + anno_path: annotations/val.json + dataset_dir: dataset/VisDrone2019_coco + +TestDataset: + !ImageFolder + anno_path: annotations/val.json diff --git a/configs/faster_rcnn/faster_rcnn_r50_fpn_1x_visdrone.yml b/configs/sniper/faster_rcnn_r50_fpn_1x_visdrone.yml similarity index 89% rename from configs/faster_rcnn/faster_rcnn_r50_fpn_1x_visdrone.yml rename to configs/sniper/faster_rcnn_r50_fpn_1x_visdrone.yml index e6f5abedb..583f403a2 100644 --- a/configs/faster_rcnn/faster_rcnn_r50_fpn_1x_visdrone.yml +++ b/configs/sniper/faster_rcnn_r50_fpn_1x_visdrone.yml @@ -5,7 +5,7 @@ _BASE_: [ '_base_/faster_rcnn_r50_fpn.yml', '_base_/faster_fpn_reader.yml', ] -weights: output/faster_rcnn_r50_fpn_1x_coco_visdrone/model_final +weights: output/faster_rcnn_r50_fpn_1x_visdrone/model_final metric: COCO diff --git a/configs/sniper/faster_rcnn_r50_fpn_2x_sniper_coco.yml b/configs/sniper/faster_rcnn_r50_fpn_2x_sniper_coco.yml deleted file mode 100644 index daebb5154..000000000 --- a/configs/sniper/faster_rcnn_r50_fpn_2x_sniper_coco.yml +++ /dev/null @@ -1,15 +0,0 @@ -_BASE_: [ - 'faster_rcnn_r50_fpn_1x_sniper_coco.yml', -] -weights: output/faster_rcnn_r50_fpn_2x_sniper_coco/model_final - -epoch: 24 -LearningRate: - base_lr: 0.01 - schedulers: - - !PiecewiseDecay - gamma: 0.1 - milestones: [16, 22] - - !LinearWarmup - start_factor: 0.1 - steps: 1000 diff --git a/configs/sniper/faster_rcnn_r50_vd_1x_coco_sniper.yml b/configs/sniper/faster_rcnn_r50_vd_1x_coco_sniper.yml deleted file mode 100644 index fbf674dc7..000000000 --- a/configs/sniper/faster_rcnn_r50_vd_1x_coco_sniper.yml +++ /dev/null @@ -1,19 +0,0 @@ -_BASE_: [ - '../datasets/sniper_coco_detection.yml', - '../runtime.yml', - '../faster_rcnn/_base_/optimizer_1x.yml', - '../faster_rcnn/_base_/faster_rcnn_r50.yml', - '_base_/faster_reader.yml', -] - -pretrain_weights: https://paddledet.bj.bcebos.com/models/faster_rcnn_r50_vd_1x_coco.pdparams -weights: output/faster_rcnn_r50_vd_1x_coco/model_final - -ResNet: - # index 0 stands for res2 - depth: 50 - variant: d - norm_type: bn - freeze_at: 0 - return_idx: [2] - num_stages: 3 diff --git a/configs/sniper/faster_rcnn_r50_vd_fpn_2x_sniper_coco.yml b/configs/sniper/faster_rcnn_r50_vd_fpn_2x_sniper_coco.yml deleted file mode 100644 index 3667319ce..000000000 --- a/configs/sniper/faster_rcnn_r50_vd_fpn_2x_sniper_coco.yml +++ /dev/null @@ -1,25 +0,0 @@ -_BASE_: [ - 'faster_rcnn_r50_fpn_1x_sniper_coco.yml', -] -pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/ResNet50_vd_pretrained.pdparams -weights: output/faster_rcnn_r50_vd_fpn_2x_sniper_coco/model_final - -ResNet: - # index 0 stands for res2 - depth: 50 - variant: d - norm_type: bn - freeze_at: 0 - return_idx: [0,1,2,3] - num_stages: 4 - -epoch: 24 -LearningRate: - base_lr: 0.01 - schedulers: - - !PiecewiseDecay - gamma: 0.1 - milestones: [16, 22] - - !LinearWarmup - start_factor: 0.1 - steps: 1000 diff --git a/configs/sniper/ppyolo_r50vd_dcn_1x_sniper.yml b/configs/sniper/ppyolo_r50vd_dcn_1x_sniper.yml deleted file mode 100644 index da634b2b1..000000000 --- a/configs/sniper/ppyolo_r50vd_dcn_1x_sniper.yml +++ /dev/null @@ -1,32 +0,0 @@ -_BASE_: [ - '../datasets/sniper_coco_detection.yml', - '../runtime.yml', - '../ppyolo/_base_/ppyolo_r50vd_dcn.yml', - '../ppyolo/_base_/optimizer_1x.yml', - './_base_/ppyolo_reader.yml', -] - -snapshot_epoch: 8 -use_ema: true -weights: output/ppyolo_r50vd_dcn_1x_minicoco/model_final - - -LearningRate: - base_lr: 0.005 - schedulers: - - !PiecewiseDecay - gamma: 0.1 - milestones: - - 153 - - 173 - - !LinearWarmup - start_factor: 0. - steps: 4000 - -OptimizerBuilder: - optimizer: - momentum: 0.9 - type: Momentum - regularizer: - factor: 0.0005 - type: L2 diff --git a/configs/sniper/ppyolo_r50vd_dcn_1x_sniper_visdrone.yml b/configs/sniper/ppyolo_r50vd_dcn_1x_sniper_visdrone.yml index 58cce3505..215a79388 100644 --- a/configs/sniper/ppyolo_r50vd_dcn_1x_sniper_visdrone.yml +++ b/configs/sniper/ppyolo_r50vd_dcn_1x_sniper_visdrone.yml @@ -8,7 +8,7 @@ _BASE_: [ snapshot_epoch: 8 use_ema: true -weights: output/ppyolo_r50vd_dcn_1x_visdrone/model_final +weights: output/ppyolo_r50vd_dcn_1x_sniper_visdrone/model_final @@ -31,3 +31,26 @@ OptimizerBuilder: regularizer: factor: 0.0005 type: L2 + + + + +metric: COCO +num_classes: 9 + +TrainDataset: + !COCODataSet + image_dir: train + anno_path: annotations/train.json + dataset_dir: dataset/VisDrone2019_coco + data_fields: ['image', 'gt_bbox', 'gt_class', 'is_crowd'] + +EvalDataset: + !COCODataSet + image_dir: val + anno_path: annotations/val.json + dataset_dir: dataset/VisDrone2019_coco + +TestDataset: + !ImageFolder + anno_path: annotations/val.json diff --git a/configs/ppyolo/ppyolo_r50vd_dcn_1x_visdrone.yml b/configs/sniper/ppyolo_r50vd_dcn_1x_visdrone.yml similarity index 90% rename from configs/ppyolo/ppyolo_r50vd_dcn_1x_visdrone.yml rename to configs/sniper/ppyolo_r50vd_dcn_1x_visdrone.yml index 0f02b35a0..ea9ca58d6 100644 --- a/configs/ppyolo/ppyolo_r50vd_dcn_1x_visdrone.yml +++ b/configs/sniper/ppyolo_r50vd_dcn_1x_visdrone.yml @@ -8,7 +8,7 @@ _BASE_: [ snapshot_epoch: 8 use_ema: true -weights: output/ppyolo_r50vd_dcn_1x_visdrone_coco/model_final +weights: output/ppyolo_r50vd_dcn_1x_visdrone/model_final epoch: 192 @@ -51,4 +51,4 @@ EvalDataset: TestDataset: !ImageFolder - anno_path: annotations/val.json \ No newline at end of file + anno_path: annotations/val.json -- GitLab