Skip to content

FL77N/RetinaNet-Based-on-PPdet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RetinaNet

一、简介

本项目基于 PPDet 复现 RetinaNet,RetinaNet 是非常经典的单阶段目标检测算法,其使用的 Focal Loss 被众多单阶段网络采用以解决正负样本不平衡的问题。

论文:

参考项目:

二、复现精度

训练数据集为 MS-COCO train2017 ,测试数据集为 val2017.

Method Environment mAP Epoch batch_size config Dataset
r50_fpn_1x_ss_training Tesla V-100 x 8
(Facebook official)
35.7 12 16 retinanet_R-50-FPN_1x.yaml COCO
r50_fpn_1x_ss_training Tesla V-100 x 4 37.0 12 16 - COCO
r50_fpn_1x_ms_training Tesla V-100 x 8
(Facebook official)
37.4 12 16 retinanet_R_50_FPN_1x.yaml COCO
r50_fpn_1x_ms_training Tesla V-100 x 4 37.4 12 16 retinanet_r50_fpn_1x_coco.yml COCO
r50_fpn_1x_ms_training_atss Tesla V-100 x 4 39.2 12 16 atss_r50_fpn_1x_coco.yml COCO

模型下载

三、环境依赖

  • 硬件:GPU、CPU

  • 框架:

    • PaddlePaddle >= 2.1.2 PaddleDetection >= 2.1.2

四、快速开始

step1: clone

# clone this repo
git clone https://github.com/FL77N/RetinaNet-Based-on-PPdet.git
cd RetinaNet-Based-on-PPdet

安装依赖

pip install -r ./requirements.txt

step2: 训练

  • single gpu
python ./tools/train.py -c .configs/retinanet/retinanet_r50_fpn_1x_coco.yml --eval
  • mutil gpu
python -m paddle.distributed.launch --gpus 0,1,2,3 ./tools/train.py -c ./configs/retinanet/retinanet_r50_fpn_1x_coco.yml --eval

此时的输出为:

ppdet.engine INFO: Epoch: [0] [ 0/63] learning_rate: 0.001000 loss_bbox_cls: 4.332087 loss_bbox_reg: 0.630385 loss: 4.962472 eta: 0:00:11 batch_cost: 0.1884 data_cost: 0.0004 ips: 10.6183 images/s
...

step3: 评估

  • eval
python ./tools/eval.py -c ./configs/retinanet/retinanet_r50_fpn_1x_coco.yml -o weights=best_model.pdparams

此时的输出为:

ppdet.engine INFO: Eval iter: 0
ppdet.metrics.metrics INFO: The bbox result is saved to bbox.json.
loading annotations into memory...
...

step4: 使用预训练模型预测

configs/your dir/your config.yml 为预测模型的配置文件,通过 infer_img 指定需要预测的图片,通过 weights 加载训练好的模型。

python tools/infer.py -c configs/your dir/your config.yml --infer_img=your image.jpg -o weights=your best model.pdparams

五、代码结构与详细说明

5.1 代码结构

├─config                          # 配置
├─dataset                         # 数据集加载
├─deploy                          # 模型部署
├─output_infer                    # infer 可视化输出
├─ppdet                           # 模型
├─tipc                            # tipc 测试脚本
├─tools                           # 训练、推理、预测
│  README.md                      # readme
│  requirement.txt                # 依赖
│  train-log.log                  # 训练日志

5.2 参数说明

训练、推理、测试相关参数设置

优化器相关参数设置

数据集加载相关设置

5.3 训练流程

单机训练

python ./tools/train.py -c your_config_file

多机训练

python -m paddle.distributed.launch --gpus 0,1,2,3... ./tools/train.py -c your_config_file

训练输出

执行训练开始后,将得到类似如下的输出。每一轮batch训练将会打印当前epoch、step以及loss值。

ppdet.engine INFO: Epoch: [0] [ 0/63] learning_rate: 0.001000 loss_bbox_cls: 4.332087 loss_bbox_reg: 0.630385 loss: 4.962472 eta: 0:00:11 batch_cost: 0.1884 data_cost: 0.0004 ips: 10.6183 images/s
...

5.4 评估流程

python ./tools/eval.py -c your_config_file -o weights=your_best_model.pdparams

此时的输出为:

ppdet.engine INFO: Eval iter: 0
ppdet.metrics.metrics INFO: The bbox result is saved to bbox.json.
loading annotations into memory...

5.5 测试流程

python tools/infer.py -c configs/your dir/your config.yml --infer_img=your image.jpg -o weights=your best model.pdparams

此时的输出结果保存在output下面

5.6 使用预训练模型预测

使用预训练模型预测的流程如下:

step1: 下载预训练模型

step2: 使用预训练模型完成预测

python tools/infer.py -c ./configs/retinanet/retinanet_r50_fpn_1x_coco.yml --infer_img=your image.jpg -o weights=best_model.pdparams

5.7 TIPC测试

The tutorials of TIPC:PythonServing

The results of TIPC: PythonServing

More detail about PPDet

六、Citations

@misc{linICCV17retinanet,
      Author = {Tsung-Yi Lin},
      Title = {RetinaNet},
      Booktitle = {International Conference on Computer Vision ({ICCV})},
      Year = {2017}
}

七、TODO

  • C++ 部署

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published