From 573d7314da78d6e279c4c28921bdc36da3dbed91 Mon Sep 17 00:00:00 2001 From: Guanghua Yu <742925032@qq.com> Date: Thu, 7 Apr 2022 18:48:00 +0800 Subject: [PATCH] add picodet quant model (#5617) --- configs/picodet/README.md | 31 +++++++------------ configs/picodet/README_en.md | 31 +++++++------------ .../slim/quant/picodet_s_416_lcnet_quant.yml | 22 +++++++++++++ 3 files changed, 46 insertions(+), 38 deletions(-) create mode 100644 configs/slim/quant/picodet_s_416_lcnet_quant.yml diff --git a/configs/picodet/README.md b/configs/picodet/README.md index 4ec08a7a4..7f4e6a539 100644 --- a/configs/picodet/README.md +++ b/configs/picodet/README.md @@ -220,9 +220,10 @@ paddle2onnx --model_dir output_inference/picodet_s_320_coco_lcnet/ \ ### 部署 -- PaddleInference demo [Python](../../deploy/python) & [C++](../../deploy/cpp) +- OpenVINO demo [Python](../../deploy/third_engine/demo/openvino/python) - [PaddleLite C++ demo](../../deploy/lite) - [Android demo(Paddle Lite)](https://github.com/PaddlePaddle/Paddle-Lite-Demo/tree/develop/object_detection/android/app/cxx/picodet_detection_demo) +- PaddleInference demo [Python](../../deploy/python) & [C++](../../deploy/cpp) Android demo可视化: @@ -237,43 +238,35 @@ Android demo可视化: 依赖包: - PaddlePaddle >= 2.2.2 -- PaddleSlim >= 2.2.1 +- PaddleSlim >= 2.2.2 **安装:** ```shell -pip install paddleslim==2.2.1 +pip install paddleslim==2.2.2 ``` -
-量化训练 (点击展开) +
+量化训练 开始量化训练: ```shell -python tools/train.py -c configs/picodet/picodet_s_320_coco_lcnet.yml \ - --slim_config configs/slim/quant/picodet_s_quant.yml --eval +python tools/train.py -c configs/picodet/picodet_s_416_coco_lcnet.yml \ + --slim_config configs/slim/quant/picodet_s_416_lcnet_quant.yml --eval ``` - 更多细节请参考[slim文档](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/slim)
-
-离线量化 (点击展开) - -校准及导出量化模型: +- 量化训练Model ZOO: -```shell -python tools/post_quant.py -c configs/picodet/picodet_s_320_coco_lcnet.yml \ - --slim_config configs/slim/post_quant/picodet_s_ptq.yml -``` - -- 注意: 离线量化模型精度问题正在解决中. - -
+| 量化模型 | 输入尺寸 | mAPval
0.5:0.95 | Configs | Weight | Inference Model | Paddle Lite(INT8) | +| :-------- | :--------: | :--------------------: | :-------: | :----------------: | :----------------: | :----------------: | +| PicoDet-S | 416*416 | 31.5 | [config](./picodet_s_416_coco_lcnet.yml) | [slim config](../slim/quant/picodet_s_416_lcnet_quant.yml) | [model](https://paddledet.bj.bcebos.com/models/picodet_s_416_coco_lcnet_quant.pdparams) | [w/ 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_s_416_coco_lcnet_quant.tar) | [w/o 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_s_416_coco_lcnet_quant_non_postprocess.tar) | [w/ 后处理](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_s_416_coco_lcnet_quant.nb) | [w/o 后处理](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_s_416_coco_lcnet_quant_non_postprocess.nb) | ## 非结构化剪枝 diff --git a/configs/picodet/README_en.md b/configs/picodet/README_en.md index eb8d12b57..c1a9483fa 100644 --- a/configs/picodet/README_en.md +++ b/configs/picodet/README_en.md @@ -216,9 +216,10 @@ paddle2onnx --model_dir output_inference/picodet_s_320_coco_lcnet/ \ ### Deploy -- PaddleInference demo [Python](../../deploy/python) & [C++](../../deploy/cpp) +- OpenVINO demo [Python](../../deploy/third_engine/demo/openvino/python) - [PaddleLite C++ demo](../../deploy/lite) - [Android demo(Paddle Lite)](https://github.com/PaddlePaddle/Paddle-Lite-Demo/tree/develop/object_detection/android/app/cxx/picodet_detection_demo) +- PaddleInference demo [Python](../../deploy/python) & [C++](../../deploy/cpp) Android demo visualization: @@ -233,43 +234,35 @@ Android demo visualization: Requirements: - PaddlePaddle >= 2.2.2 -- PaddleSlim >= 2.2.1 +- PaddleSlim >= 2.2.2 **Install:** ```shell -pip install paddleslim==2.2.1 +pip install paddleslim==2.2.2 ```
-
-Quant aware (click to expand) +
+Quant aware Configure the quant config and start training: ```shell -python tools/train.py -c configs/picodet/picodet_s_320_coco_lcnet.yml \ - --slim_config configs/slim/quant/picodet_s_quant.yml --eval +python tools/train.py -c configs/picodet/picodet_s_416_coco_lcnet.yml \ + --slim_config configs/slim/quant/picodet_s_416_lcnet_quant.yml --eval ``` - More detail can refer to [slim document](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/slim)
-
-Post quant (click to expand) - -Configure the post quant config and start calibrate model: +- Quant Aware Model ZOO: -```shell -python tools/post_quant.py -c configs/picodet/picodet_s_320_coco_lcnet.yml \ - --slim_config configs/slim/post_quant/picodet_s_ptq.yml -``` - -- Notes: Now the accuracy of post quant is abnormal and this problem is being solved. - -
+| Quant Model | Input size | mAPval
0.5:0.95 | Configs | Weight | Inference Model | Paddle Lite(INT8) | +| :-------- | :--------: | :--------------------: | :-------: | :----------------: | :----------------: | :----------------: | +| PicoDet-S | 416*416 | 31.5 | [config](./picodet_s_416_coco_lcnet.yml) | [slim config](../slim/quant/picodet_s_416_lcnet_quant.yml) | [model](https://paddledet.bj.bcebos.com/models/picodet_s_416_coco_lcnet_quant.pdparams) | [w/ postprocess](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_s_416_coco_lcnet_quant.tar) | [w/o postprocess](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_s_416_coco_lcnet_quant_non_postprocess.tar) | [w/ postprocess](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_s_416_coco_lcnet_quant.nb) | [w/o postprocess](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_s_416_coco_lcnet_quant_non_postprocess.nb) | ## Unstructured Pruning diff --git a/configs/slim/quant/picodet_s_416_lcnet_quant.yml b/configs/slim/quant/picodet_s_416_lcnet_quant.yml new file mode 100644 index 000000000..000807ab6 --- /dev/null +++ b/configs/slim/quant/picodet_s_416_lcnet_quant.yml @@ -0,0 +1,22 @@ +pretrain_weights: https://paddledet.bj.bcebos.com/models/picodet_s_416_coco_lcnet.pdparams +slim: QAT + +QAT: + quant_config: { + 'activation_preprocess_type': 'PACT', + 'weight_quantize_type': 'channel_wise_abs_max', 'activation_quantize_type': 'moving_average_abs_max', + 'weight_bits': 8, 'activation_bits': 8, 'dtype': 'int8', 'window_size': 10000, 'moving_rate': 0.9, + 'quantizable_layer_type': ['Conv2D', 'Linear']} + print_model: False + +TrainReader: + batch_size: 48 + +LearningRate: + base_lr: 0.024 + schedulers: + - !CosineDecay + max_epochs: 300 + - !LinearWarmup + start_factor: 0.1 + steps: 300 -- GitLab