本项目基于 PPDet 复现 Fast-RCNN,Fast-RCNN 是非常经典的目标检测算法,是 SPP 的改进,也是著名的两阶段网络 Faster-RCNN 的基础。
论文:
参考项目:
训练数据集为 MS-COCO train2017 ,测试数据集为 val2017.
Method | Environment | mAP | Epoch | batch_size | config | Dataset |
---|---|---|---|---|---|---|
r50_fpn_1x_ms_training | Tesla V-100 x 4 | 37.7 | 12 | 16 | fast_rcnn_r50_fpn_1x_coco.yml | COCO |
模型下载
- The multi scale training best model and train-log are saved to: Baidu Aistudio
- The COCO PrecomputedProposals is saved to: Baidu Aistudio
-
硬件:GPU、CPU
-
框架:
- PaddlePaddle >= 2.1.2 PaddleDetection >= 2.2.0
# clone this repo
git clone https://github.com/FL77N/Fast-RCNN-on-PPDet.git
cd Fast-RCNN-on-PPDet
安装依赖
pip install -r ./requirements.txt
- single gpu
python ./tools/train.py -c ./configs/fast_rcnn/fast_rcnn_r50_fpn_1x_coco.yml --eval
- mutil gpu
python -m paddle.distributed.launch --gpus 0,1,2,3 ./tools/train.py -c ./configs/fast_rcnn/fast_rcnn_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/fast_rcnn/fast_rcnn_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 # 模型部署
├─demo # demo
├─output # infer 可视化输出
├─ppdet # 模型
├─test_tipc # tipc 脚本
├─tools # 训练、推理、预测
│ README.md # readme
│ requirement.txt # 依赖
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 and train-log are saved to: Baidu Aistudio
step2: 使用预训练模型完成预测
python tools/infer.py -c ./configs/fast_rcnn/fast_rcnn_r50_fpn_1x_coco.yml --infer_img=your image.jpg -o weights=best_model.pdparams
推理效果如下:
@inproceedings{girshickICCV15fastrcnn,
Author = {Ross Girshick},
Title = {Fast R-CNN},
Booktitle = {International Conference on Computer Vision ({ICCV})},
Year = {2015}
}
- TIPC 解决动态 shape bug 支持 TensorRT 加速 --- Done