本项目基于 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 |
模型下载
- The single scale training best model is saved to: Baidu Aistudio
- The multi scale training best model is saved to: Baidu Aistudio
-
硬件:GPU、CPU
-
框架:
- PaddlePaddle >= 2.1.2 PaddleDetection >= 2.1.2
# clone this repo
git clone https://github.com/FL77N/RetinaNet-Based-on-PPdet.git
cd RetinaNet-Based-on-PPdet
安装依赖
pip install -r ./requirements.txt
- 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
...
- 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...
...
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
├─config # 配置
├─dataset # 数据集加载
├─deploy # 模型部署
├─output_infer # infer 可视化输出
├─ppdet # 模型
├─tipc # tipc 测试脚本
├─tools # 训练、推理、预测
│ README.md # readme
│ requirement.txt # 依赖
│ train-log.log # 训练日志
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
...
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...
python tools/infer.py -c configs/your dir/your config.yml --infer_img=your image.jpg -o weights=your best model.pdparams
此时的输出结果保存在output
下面
使用预训练模型预测的流程如下:
step1: 下载预训练模型
- The multi scale training best model are saved to: Baidu Aistudio
step2: 使用预训练模型完成预测
python tools/infer.py -c ./configs/retinanet/retinanet_r50_fpn_1x_coco.yml --infer_img=your image.jpg -o weights=best_model.pdparams
The tutorials of TIPC:Python、Serving
The results of TIPC: Python、Serving
@misc{linICCV17retinanet,
Author = {Tsung-Yi Lin},
Title = {RetinaNet},
Booktitle = {International Conference on Computer Vision ({ICCV})},
Year = {2017}
}
- C++ 部署