diff --git a/example/auto_compression/image_classification/README.md b/example/auto_compression/image_classification/README.md index 3917f141526b254fe33697ce570841d697bcb27b..53000063d47cedcfca7b858ef980065c4e419cfe 100644 --- a/example/auto_compression/image_classification/README.md +++ b/example/auto_compression/image_classification/README.md @@ -1,17 +1,19 @@ # 图像分类模型自动压缩示例 目录: -- [1. 简介](#1简介) -- [2. Benchmark](#2Benchmark) -- [3. 自动压缩流程](#自动压缩流程) - - [3.1 准备环境](#31-准备准备) - - [3.2 准备数据集](#32-准备数据集) - - [3.3 准备预测模型](#33-准备预测模型) - - [3.4 自动压缩并产出模型](#34-自动压缩并产出模型) -- [4. 预测部署](#4预测部署) - - [4.1 Python预测推理](#41-Python预测推理) - - [4.2 PaddleLite端侧部署](#42-PaddleLite端侧部署) -- [5. FAQ](5FAQ) +- [图像分类模型自动压缩示例](#图像分类模型自动压缩示例) + - [1. 简介](#1-简介) + - [2. Benchmark](#2-benchmark) + - [PaddleClas模型](#paddleclas模型) + - [3. 自动压缩流程](#3-自动压缩流程) + - [3.1 准备环境](#31-准备环境) + - [3.2 准备数据集](#32-准备数据集) + - [3.3 准备预测模型](#33-准备预测模型) + - [3.4 自动压缩并产出模型](#34-自动压缩并产出模型) + - [4.预测部署](#4预测部署) + - [4.1 Paddle Inference 验证性能](#41-paddle-inference-验证性能) + - [4.2 PaddleLite端侧部署](#42-paddlelite端侧部署) + - [5.FAQ](#5faq) ## 1. 简介 @@ -34,7 +36,7 @@ | PPLCNetV2_base | Baseline | 76.86 | - | 36.50 | - | [Model](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNetV2_base_infer.tar) | | PPLCNetV2_base | 量化+蒸馏 | 76.39 | - | 15.79 | [Config](./configs/PPLCNetV2_base/qat_dis.yaml) | [Model](https://paddle-slim-models.bj.bcebos.com/act/PPLCNetV2_base_QAT.tar) | | PPHGNet_tiny | Baseline | 79.59 | 2.82 | - | - |[Model](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPHGNet_tiny_infer.tar) | -| PPHGNet_tiny | 量化+蒸馏 | 79.24 | 0.98 | - | [Config](./configs/PPHGNet_tiny/qat_dis.yaml) | [Model](https://paddle-slim-models.bj.bcebos.com/act/PPHGNet_tiny_QAT.tar) | +| PPHGNet_tiny | 量化+蒸馏 | 78.86 | 0.98 | - | [Config](./configs/PPHGNet_tiny/qat_dis.yaml) | [Model](https://paddle-slim-models.bj.bcebos.com/act/PPHGNet_tiny_QAT.tar) | | InceptionV3 | Baseline | 79.14 | 4.79 | - | - | [Model](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/InceptionV3_infer.tar) | | InceptionV3 | 量化+蒸馏 | 78.32 | 1.47 | - | [Config](./configs/InceptionV3/qat_dis.yaml) | [Model](https://paddle-slim-models.bj.bcebos.com/act/InceptionV3_QAT.tar) | | EfficientNetB0 | Baseline | 77.02 | 1.95 | - | - | [Model](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/EfficientNetB0_infer.tar) | diff --git a/example/auto_compression/image_classification/configs/PPHGNet_tiny/qat_dis.yaml b/example/auto_compression/image_classification/configs/PPHGNet_tiny/qat_dis.yaml index 50eb9898d625717291b9d15c72521df8af796095..66fe849af74e0783d6be6edb5dc82f650ce06842 100644 --- a/example/auto_compression/image_classification/configs/PPHGNet_tiny/qat_dis.yaml +++ b/example/auto_compression/image_classification/configs/PPHGNet_tiny/qat_dis.yaml @@ -7,9 +7,7 @@ Global: Distillation: alpha: 1.0 - loss: l2 - node: - - softmax_1.tmp_0 + loss: soft_label QuantAware: use_pact: true @@ -29,10 +27,10 @@ QuantAware: TrainConfig: epochs: 1 - eval_iter: 500 + eval_iter: 5000 learning_rate: type: CosineAnnealingDecay - learning_rate: 0.015 + learning_rate: 0.001 optimizer_builder: optimizer: type: Momentum diff --git a/example/auto_compression/semantic_segmentation/configs/pp_humanseg/pp_humanseg_qat.yaml b/example/auto_compression/semantic_segmentation/configs/pp_humanseg/pp_humanseg_qat.yaml index 5b497a1e61026f9b3321c3ac78972f50c331c01f..f0f13e35f4d6645a11ddad5a9f2e43c0fc3db36b 100644 --- a/example/auto_compression/semantic_segmentation/configs/pp_humanseg/pp_humanseg_qat.yaml +++ b/example/auto_compression/semantic_segmentation/configs/pp_humanseg/pp_humanseg_qat.yaml @@ -19,7 +19,7 @@ QuantAware: TrainConfig: epochs: 1 eval_iter: 400 - learning_rate: 0.0005 + learning_rate: 0.00005 optimizer_builder: optimizer: type: SGD diff --git a/paddleslim/analysis/latency_predictor.py b/paddleslim/analysis/latency_predictor.py index 0e383d1e353be06a6500b2299269e6d0afe85059..761d0c2de0f7a79568ec5b50a0f6ee26753096b7 100644 --- a/paddleslim/analysis/latency_predictor.py +++ b/paddleslim/analysis/latency_predictor.py @@ -104,7 +104,8 @@ class TableLatencyPredictor(LatencyPredictor): _logger.info("pip install paddleslim-opt-tools") out = shutil.which('paddle_lite_opt') if out is None: - pip.main(['install', 'paddleslim-opt-tools']) + from pip._internal import main + main(['install', 'paddleslim-opt-tools']) def _initial_table(self): if self.table_file in TableLatencyPredictor.hardware_list: diff --git a/paddleslim/quant/post_quant_hpo.py b/paddleslim/quant/post_quant_hpo.py index 73623894ec9cbad258a594efbdbfc0a6bd29f7d8..c402ce4cf92b6cb19c2ca4e85dcb8b78eece4db9 100755 --- a/paddleslim/quant/post_quant_hpo.py +++ b/paddleslim/quant/post_quant_hpo.py @@ -415,9 +415,12 @@ def quant_post_hpo( try: import smac + assert smac.version == '1.4.0' except: - os.system('python -m pip install -U smac') - # smac + _logger.warning( + "smac==1.4.0 is required, please use \"pip install smac==1.4.0\".") + os.system('python -m pip install smac==1.4.0') + from ConfigSpace.hyperparameters import CategoricalHyperparameter, \ UniformFloatHyperparameter, UniformIntegerHyperparameter from smac.configspace import ConfigurationSpace