Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
jerrywgz 94861c24b2 | 1 year ago | |
---|---|---|
.. | ||
distill | 1 year ago | |
extensions | 1 year ago | |
ofa | 2 years ago | |
post_quant | 2 years ago | |
prune | 2 years ago | |
quant | 1 year ago | |
README.md | 1 year ago | |
README_en.md | 1 year ago |
在PaddleDetection中, 提供了基于PaddleSlim进行模型压缩的完整教程和benchmark。目前支持的方法:
推荐您使用剪裁和蒸馏联合训练,或者使用剪裁、量化训练和离线量化,进行检测模型压缩。 下面以YOLOv3为例,进行剪裁、蒸馏和量化实验。
PaddleDetection、 PaddlePaddle与PaddleSlim 版本关系:
PaddleDetection版本 | PaddlePaddle版本 | PaddleSlim版本 | 备注 |
---|---|---|---|
release/2.3 | >= 2.1 | 2.1 | 离线量化依赖Paddle 2.2及PaddleSlim 2.2 |
release/2.1 | 2.2 | >= 2.1.0 | 2.1 |
release/2.0 | >= 2.0.1 | 2.0 | 量化依赖Paddle 2.1及PaddleSlim 2.1 |
pip install paddleslim -i https://pypi.tuna.tsinghua.edu.cn/simple
git clone https://github.com/PaddlePaddle/PaddleSlim.git
cd PaddleSlim
python setup.py install
python tools/train.py -c configs/{MODEL.yml} --slim_config configs/slim/{SLIM_CONFIG.yml}
-c
: 指定模型配置文件。--slim_config
: 指定压缩策略配置文件。python tools/eval.py -c configs/{MODEL.yml} --slim_config configs/slim/{SLIM_CONFIG.yml} -o weights=output/{SLIM_CONFIG}/model_final
-c
: 指定模型配置文件。--slim_config
: 指定压缩策略配置文件。-o weights
: 指定压缩算法训好的模型路径。python tools/infer.py -c configs/{MODEL.yml} --slim_config configs/slim/{SLIM_CONFIG.yml} \
-o weights=output/{SLIM_CONFIG}/model_final
--infer_img={IMAGE_PATH}
-c
: 指定模型配置文件。--slim_config
: 指定压缩策略配置文件。-o weights
: 指定压缩算法训好的模型路径。--infer_img
: 指定测试图像路径。python tools/export_model.py -c configs/{MODEL.yml} --slim_config configs/slim/{SLIM_CONFIG.yml} -o weights=output/{SLIM_CONFIG}/model_final
-c
: 指定模型配置文件。--slim_config
: 指定压缩策略配置文件。-o weights
: 指定压缩算法训好的模型路径。模型 | 压缩策略 | GFLOPs | 模型体积(MB) | 输入尺寸 | 预测时延(SD855) | Box AP | 下载 | 模型配置文件 | 压缩算法配置文件 |
---|---|---|---|---|---|---|---|---|---|
YOLOv3-MobileNetV1 | baseline | 24.13 | 93 | 608 | 332.0ms | 75.1 | 下载链接 | 配置文件 | - |
YOLOv3-MobileNetV1 | 剪裁-l1_norm(sensity) | 15.78(-34.49%) | 66(-29%) | 608 | - | 78.4(+3.3) | 下载链接 | 配置文件 | slim配置文件 |
模型 | 压缩策略 | GFLOPs | 模型体积(MB) | 输入尺寸 | 预测时延(SD855) | Box AP | 下载 | 模型配置文件 | 压缩算法配置文件 |
---|---|---|---|---|---|---|---|---|---|
PP-YOLO-MobileNetV3_large | baseline | -- | 18.5 | 608 | 25.1ms | 23.2 | 下载链接 | 配置文件 | - |
PP-YOLO-MobileNetV3_large | 剪裁-FPGM | -37% | 12.6 | 608 | - | 22.3 | 下载链接 | 配置文件 | slim配置文件 |
YOLOv3-DarkNet53 | baseline | -- | 238.2 | 608 | - | 39.0 | 下载链接 | 配置文件 | - |
YOLOv3-DarkNet53 | 剪裁-FPGM | -24% | - | 608 | - | 37.6 | 下载链接 | 配置文件 | slim配置文件 |
PP-YOLO_R50vd | baseline | -- | 183.3 | 608 | - | 44.8 | 下载链接 | 配置文件 | - |
PP-YOLO_R50vd | 剪裁-FPGM | -35% | - | 608 | - | 42.1 | 下载链接 | 配置文件 | slim配置文件 |
说明:
模型 | 压缩策略 | 输入尺寸 | 模型体积(MB) | 预测时延(V100) | 预测时延(SD855) | Box AP | 下载 | Inference模型下载 | 模型配置文件 | 压缩算法配置文件 |
---|---|---|---|---|---|---|---|---|---|---|
PP-YOLOE-l | baseline | 640 | - | 11.2ms(trt_fp32) | 7.7ms(trt_fp16) | -- | 50.9 | 下载链接 | - | 配置文件 | - |
PP-YOLOE-l | 普通在线量化 | 640 | - | 6.7ms(trt_int8) | -- | 48.8 | 下载链接 | - | 配置文件 | 配置文件 |
PP-YOLOv2_R50vd | baseline | 640 | 208.6 | 19.1ms | -- | 49.1 | 下载链接 | 下载链接 | 配置文件 | - |
PP-YOLOv2_R50vd | PACT在线量化 | 640 | -- | 17.3ms | -- | 48.1 | 下载链接 | 下载链接 | 配置文件 | 配置文件 |
PP-YOLO_R50vd | baseline | 608 | 183.3 | 17.4ms | -- | 44.8 | 下载链接 | 下载链接 | 配置文件 | - |
PP-YOLO_R50vd | PACT在线量化 | 608 | 67.3 | 13.8ms | -- | 44.3 | 下载链接 | 下载链接 | 配置文件 | 配置文件 |
PP-YOLO-MobileNetV3_large | baseline | 320 | 18.5 | 2.7ms | 27.9ms | 23.2 | 下载链接 | 下载链接 | 配置文件 | - |
PP-YOLO-MobileNetV3_large | 普通在线量化 | 320 | 5.6 | -- | 25.1ms | 24.3 | 下载链接 | 下载链接 | 配置文件 | 配置文件 |
YOLOv3-MobileNetV1 | baseline | 608 | 94.2 | 8.9ms | 332ms | 29.4 | 下载链接 | 下载链接 | 配置文件 | - |
YOLOv3-MobileNetV1 | 普通在线量化 | 608 | 25.4 | 6.6ms | 248ms | 30.5 | 下载链接 | 下载链接 | 配置文件 | slim配置文件 |
YOLOv3-MobileNetV3 | baseline | 608 | 90.3 | 9.4ms | 367.2ms | 31.4 | 下载链接 | 下载链接 | 配置文件 | - |
YOLOv3-MobileNetV3 | PACT在线量化 | 608 | 24.4 | 8.0ms | 280.0ms | 31.1 | 下载链接 | 下载链接 | 配置文件 | slim配置文件 |
YOLOv3-DarkNet53 | baseline | 608 | 238.2 | 16.0ms | -- | 39.0 | 下载链接 | 下载链接 | 配置文件 | - |
YOLOv3-DarkNet53 | 普通在线量化 | 608 | 78.8 | 12.4ms | -- | 38.8 | 下载链接 | 下载链接 | 配置文件 | slim配置文件 |
SSD-MobileNet_v1 | baseline | 300 | 22.5 | 4.4ms | 26.6ms | 73.8 | 下载链接 | 下载链接 | 配置文件 | - |
SSD-MobileNet_v1 | 普通在线量化 | 300 | 7.1 | -- | 21.5ms | 72.9 | 下载链接 | 下载链接 | 配置文件 | slim配置文件 |
Mask-ResNet50-FPN | baseline | (800, 1333) | 174.1 | 359.5ms | -- | 39.2/35.6 | 下载链接 | 下载链接 | 配置文件 | - |
Mask-ResNet50-FPN | 普通在线量化 | (800, 1333) | -- | -- | -- | 39.7(+0.5)/35.9(+0.3) | 下载链接 | 下载链接 | 配置文件 | slim配置文件 |
说明:
需要准备val集,用来对离线量化模型进行校准,运行方式:
python tools/post_quant.py -c configs/{MODEL.yml} --slim_config configs/slim/post_quant/{SLIM_CONFIG.yml}
例如:
python3.7 tools/post_quant.py -c configs/ppyolo/ppyolo_mbv3_large_coco.yml --slim_config=configs/slim/post_quant/ppyolo_mbv3_large_ptq.yml
模型 | 压缩策略 | 输入尺寸 | Box AP | 下载 | 模型配置文件 | 压缩算法配置文件 |
---|---|---|---|---|---|---|
YOLOv3-MobileNetV1 | baseline | 608 | 29.4 | 下载链接 | 配置文件 | - |
YOLOv3-MobileNetV1 | 蒸馏 | 608 | 31.0(+1.6) | 下载链接 | 配置文件 | slim配置文件 |
模型 | 压缩策略 | 输入尺寸 | GFLOPs | 模型体积(MB) | 预测时延(SD855) | Box AP | 下载 | 模型配置文件 | 压缩算法配置文件 |
---|---|---|---|---|---|---|---|---|---|
YOLOv3-MobileNetV1 | baseline | 608 | 24.65 | 94.2 | 332.0ms | 29.4 | 下载链接 | 配置文件 | - |
YOLOv3-MobileNetV1 | 蒸馏+剪裁 | 608 | 7.54(-69.4%) | 30.9(-67.2%) | 166.1ms | 28.4(-1.0) | 下载链接 | 配置文件 | slim配置文件 |
YOLOv3-MobileNetV1 | 剪裁+量化 | 608 | - | - | - | - | - | 配置文件 | slim配置文件 |
PaddleDetection是一个基于PaddlePaddle的目标检测端到端开发套件,在提供丰富的模型组件和测试基准的同时,注重端到端的产业落地应用,通过打造产业级特色模型|工具、建设产业应用范例等手段,帮助开发者实现数据准备、模型选型、模型训练、模型部署的全流程打通,快速进行落地应用。
Python Markdown C++ Text Shell other
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》