From 2fd409628cb610a967849458621b2f1ad4807c99 Mon Sep 17 00:00:00 2001 From: zhouzj <41366441+zzjjay@users.noreply.github.com> Date: Fri, 24 Mar 2023 10:25:18 +0800 Subject: [PATCH] Update SMAC version requirements (#1684) --- .../image_classification/README.md | 26 ++++++++++--------- .../configs/PPHGNet_tiny/qat_dis.yaml | 8 +++--- .../configs/pp_humanseg/pp_humanseg_qat.yaml | 2 +- paddleslim/analysis/latency_predictor.py | 3 ++- paddleslim/quant/post_quant_hpo.py | 7 +++-- 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/example/auto_compression/image_classification/README.md b/example/auto_compression/image_classification/README.md index 3917f141..53000063 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 50eb9898..66fe849a 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 5b497a1e..f0f13e35 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 0e383d1e..761d0c2d 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 73623894..c402ce4c 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 -- GitLab