[Quantization] Add new PaddleSeg models quantization support. (#953)

* Fix links in readme

* Fix links in readme

* Update PPOCRv2/v3 examples

* Update auto compression configs

* Add neww quantization  support for paddleclas model

* Update quantized Yolov6s model download link

* Improve PPOCR comments

* Add English doc for quantization

* Fix PPOCR rec model bug

* Add  new paddleseg quantization support

* Add  new paddleseg quantization support

* Add  new paddleseg quantization support

* Add  new paddleseg quantization support
This commit is contained in:
yunyaoXYY
2022-12-25 16:33:57 +08:00
committed by GitHub
parent 2431890f73
commit 2d3d941372
5 changed files with 120 additions and 3 deletions

View File

@@ -103,13 +103,15 @@ FastDeploy目前为用户提供了多个模型的压缩[config](./configs/)文
| [mobilenetv3_large_x1_0_quant](./configs/classification/mobilenetv3_large_x1_0_quant.yaml) | [mobilenetv3_large_x1_0](https://bj.bcebos.com/paddlehub/fastdeploy/MobileNetV3_large_x1_0_ssld_infer.tgz) | |
| [pphgnet_tiny_quant](./configs/classification/pphgnet_tiny_quant.yaml) | [pphgnet_tiny](https://bj.bcebos.com/paddlehub/fastdeploy/PPHGNet_tiny_ssld_infer.tgz) | |
| [pplcnetv2_base_quant](./configs/classification/pplcnetv2_base_quant.yaml) | [pplcnetv2_base](https://bj.bcebos.com/paddlehub/fastdeploy/PPLCNetV2_base_infer.tgz) | |
| [yolov5s_quant](./configs/detection/yolov5s_quant.yaml) | [yolov5s](https://paddle-slim-models.bj.bcebos.com/act/yolov5s.onnx) | |
| [yolov6s_quant](./configs/detection/yolov6s_quant.yaml) | [yolov6s](https://paddle-slim-models.bj.bcebos.com/act/yolov6s.onnx) | |
| [yolov7_quant](./configs/detection/yolov7_quant.yaml) | [yolov7](https://paddle-slim-models.bj.bcebos.com/act/yolov7.onnx) | |
| [ppyoloe_withNMS_quant](./configs/detection/ppyoloe_withNMS_quant.yaml) | [ppyoloe_l](https://bj.bcebos.com/v1/paddle-slim-models/act/ppyoloe_crn_l_300e_coco.tar) | 支持PPYOLOE的s,m,l,x系列模型, 从PaddleDetection导出模型时正常导出, 不要去除NMS |
| [ppyoloe_plus_withNMS_quant](./configs/detection/ppyoloe_plus_withNMS_quant.yaml) | [ppyoloe_plus_s](https://bj.bcebos.com/paddlehub/fastdeploy/ppyoloe_plus_crn_s_80e_coco.tar) | 支持PPYOLOE+的s,m,l,x系列模型, 从PaddleDetection导出模型时正常导出, 不要去除NMS |
| [pp_liteseg_quant](./configs/segmentation/pp_liteseg_quant.yaml) | [pp_liteseg](https://bj.bcebos.com/paddlehub/fastdeploy/PP_LiteSeg_T_STDC1_cityscapes_without_argmax_infer.tgz) | |
| [pp_liteseg_quant](./configs/segmentation/pp_liteseg_quant.yaml) | [pp_liteseg](https://bj.bcebos.com/paddlehub/fastdeploy/PP_LiteSeg_T_STDC1_cityscapes_without_argmax_infer.tgz) |
| [deeplabv3_resnet_quant](./configs/segmentation/deeplabv3_resnet_quant.yaml) | [deeplabv3_resnet101](https://bj.bcebos.com/paddlehub/fastdeploy/Deeplabv3_ResNet101_OS8_cityscapes_without_argmax_infer.tgz) | |
| [fcn_hrnet_quant](./configs/segmentation/fcn_hrnet_quant.yaml) | [fcn_hrnet](https://bj.bcebos.com/paddlehub/fastdeploy/FCN_HRNet_W18_cityscapes_without_argmax_infer.tgz) | |
| [unet_quant](./configs/segmentation/unet_quant.yaml) | [unet](https://bj.bcebos.com/paddlehub/fastdeploy/Unet_cityscapes_without_argmax_infer.tgz) | | |

View File

@@ -103,7 +103,7 @@ To complete the quantization, developers only need to provide a customized model
## 3. FastDeploy One-Click Model Auto Compression Config file examples
FastDeploy currently provides users with compression [config](./configs/) files of multiple models, and the corresponding FP32 model, Users can directly download and experience it.
| Config文件 | 待压缩的FP32模型 | 备注 |
| Config file | FP32 model | Note |
| -------------------- | ------------------------------------------------------------ |----------------------------------------- |
| [mobilenetv1_ssld_quant](./configs/classification/mobilenetv1_ssld_quant.yaml) | [mobilenetv1_ssld](https://bj.bcebos.com/paddlehub/fastdeploy/MobileNetV1_ssld_infer.tgz) | |
| [resnet50_vd_quant](./configs/classification/resnet50_vd_quant.yaml) | [resnet50_vd](https://bj.bcebos.com/paddlehub/fastdeploy/ResNet50_vd_infer.tgz) | |
@@ -117,6 +117,10 @@ FastDeploy currently provides users with compression [config](./configs/) files
| [ppyoloe_withNMS_quant](./configs/detection/ppyoloe_withNMS_quant.yaml) | [ppyoloe_l](https://bj.bcebos.com/v1/paddle-slim-models/act/ppyoloe_crn_l_300e_coco.tar) | Support PPYOLOE's s,m,l,x series models, export the model normally when exporting the model from PaddleDetection, do not remove NMS |
| [ppyoloe_plus_withNMS_quant](./configs/detection/ppyoloe_plus_withNMS_quant.yaml) | [ppyoloe_plus_s](https://bj.bcebos.com/paddlehub/fastdeploy/ppyoloe_plus_crn_s_80e_coco.tar) | Support PPYOLOE+'s s,m,l,x series models, export the model normally when exporting the model from PaddleDetection, do not remove NMS |
| [pp_liteseg_quant](./configs/segmentation/pp_liteseg_quant.yaml) | [pp_liteseg](https://bj.bcebos.com/paddlehub/fastdeploy/PP_LiteSeg_T_STDC1_cityscapes_without_argmax_infer.tgz) | |
| [deeplabv3_resnet_quant](./configs/segmentation/deeplabv3_resnet_quant.yaml) | [deeplabv3_resnet101](https://bj.bcebos.com/paddlehub/fastdeploy/Deeplabv3_ResNet101_OS8_cityscapes_without_argmax_infer.tgz) | |
| [fcn_hrnet_quant](./configs/segmentation/fcn_hrnet_quant.yaml) | [fcn_hrnet](https://bj.bcebos.com/paddlehub/fastdeploy/FCN_HRNet_W18_cityscapes_without_argmax_infer.tgz) | |
| [unet_quant](./configs/segmentation/unet_quant.yaml) | [unet](https://bj.bcebos.com/paddlehub/fastdeploy/Unet_cityscapes_without_argmax_infer.tgz) | | |
## 3. Deploy quantized models on FastDeploy

View File

@@ -0,0 +1,37 @@
Global:
model_dir: ./Deeplabv3_ResNet101_OS8_cityscapes_without_argmax_infer/
format: paddle
model_filename: model.pdmodel
params_filename: model.pdiparams
qat_image_path: ./train_stuttgart
ptq_image_path: ./train_stuttgart
input_list: ['x']
qat_preprocess: ppseg_cityscapes_qat_preprocess
ptq_preprocess: ppseg_cityscapes_ptq_preprocess
qat_batch_size: 2
Distillation:
alpha: 1.0
loss: l2
node:
- conv2d_225.tmp_0
QuantAware:
onnx_format: True
quantize_op_types:
- conv2d
- depthwise_conv2d
TrainConfig:
epochs: 1
eval_iter: 360
learning_rate: 0.0001
optimizer_builder:
optimizer:
type: SGD
weight_decay: 0.0005
PTQ:
calibration_method: 'avg' # option: avg, abs_max, hist, KL, mse
skip_tensor_list: None

View File

@@ -0,0 +1,36 @@
Global:
model_dir: ./FCN_HRNet_W18_cityscapes_without_argmax_infer
format: paddle
model_filename: model.pdmodel
params_filename: model.pdiparams
qat_image_path: ./train_stuttgart
ptq_image_path: ./train_stuttgart
input_list: ['x']
qat_preprocess: ppseg_cityscapes_qat_preprocess
ptq_preprocess: ppseg_cityscapes_ptq_preprocess
qat_batch_size: 2
Distillation:
alpha: 1.0
loss: l2
node:
- conv2d_613.tmp_1
QuantAware:
onnx_format: True
quantize_op_types:
- conv2d
- depthwise_conv2d
TrainConfig:
epochs: 20
eval_iter: 360
learning_rate: 0.0001
optimizer_builder:
optimizer:
type: SGD
weight_decay: 4.0e-05
PTQ:
calibration_method: 'avg' # option: avg, abs_max, hist, KL, mse
skip_tensor_list: None

View File

@@ -0,0 +1,38 @@
Global:
model_dir: ./Unet_cityscapes_without_argmax_infer/
format: paddle
model_filename: model.pdmodel
params_filename: model.pdiparams
qat_image_path: ./train_stuttgart
ptq_image_path: ./train_stuttgart
input_list: ['x']
qat_preprocess: ppseg_cityscapes_qat_preprocess
ptq_preprocess: ppseg_cityscapes_ptq_preprocess
qat_batch_size: 2
Distillation:
alpha: 1.0
loss: l2
node:
- conv2d_37.tmp_1
QuantAware:
onnx_format: True
quantize_op_types:
- conv2d
- depthwise_conv2d
TrainConfig:
epochs: 10
eval_iter: 180
learning_rate: 0.0005
optimizer_builder:
optimizer:
type: SGD
weight_decay: 4.0e-05
PTQ:
calibration_method: 'avg' # option: avg, abs_max, hist, KL, mse
skip_tensor_list: None