未验证 提交 860d55f6 编写于 作者: C ceci3 提交者: GitHub

[cherry pick]cancel opt_model in requirement.txt (#1261) (#1266)

上级 0b25b5f1
...@@ -9,8 +9,21 @@ PaddleSlim推出全新自动化压缩工具(ACT),旨在通过Source-Free ...@@ -9,8 +9,21 @@ PaddleSlim推出全新自动化压缩工具(ACT),旨在通过Source-Free
## 环境准备 ## 环境准备
- 安装PaddlePaddle >= 2.3版本 (从[Paddle官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)下载安装) - 安装PaddlePaddle >= 2.3 (从[Paddle官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)下载安装)
- 安装PaddleSlim develop版本 - 安装PaddleSlim >=2.3
(1)安装paddlepaddle:
```shell
# CPU
pip install paddlepaddle
# GPU
pip install paddlepaddle-gpu
```
(2)安装paddleslim:
```shell
pip install paddleslim
```
## 快速上手 ## 快速上手
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#### 3.1 准备环境 #### 3.1 准备环境
- PaddlePaddle >= 2.3 (可从[Paddle官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)下载安装) - PaddlePaddle >= 2.3 (可从[Paddle官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)下载安装)
- PaddleSlim develop版本 - PaddleSlim >= 2.3
- PaddleDet >= 2.4 - PaddleDet >= 2.4
- opencv-python - opencv-python
...@@ -46,8 +46,7 @@ pip install paddlepaddle-gpu ...@@ -46,8 +46,7 @@ pip install paddlepaddle-gpu
安装paddleslim: 安装paddleslim:
```shell ```shell
https://github.com/PaddlePaddle/PaddleSlim.git pip install paddleslim
python setup.py install
``` ```
安装paddledet: 安装paddledet:
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
- python >= 3.6 - python >= 3.6
- PaddlePaddle >= 2.3 (可从[Paddle官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)下载安装) - PaddlePaddle >= 2.3 (可从[Paddle官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)下载安装)
- PaddleSlim develop版本 - PaddleSlim >= 2.3
安装paddlepaddle: 安装paddlepaddle:
```shell ```shell
...@@ -68,8 +68,7 @@ pip install paddlepaddle-gpu ...@@ -68,8 +68,7 @@ pip install paddlepaddle-gpu
安装paddleslim: 安装paddleslim:
```shell ```shell
https://github.com/PaddlePaddle/PaddleSlim.git pip install paddleslim
python setup.py install
``` ```
#### 3.2 准备数据集 #### 3.2 准备数据集
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
#### 3.1 准备环境 #### 3.1 准备环境
- python >= 3.6 - python >= 3.6
- PaddlePaddle >= 2.3 (可从[Paddle官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)下载安装) - PaddlePaddle >= 2.3 (可从[Paddle官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)下载安装)
- PaddleSlim develop版本 - PaddleSlim >= 2.3
- PaddleNLP >= 2.3 - PaddleNLP >= 2.3
安装paddlepaddle: 安装paddlepaddle:
...@@ -61,8 +61,7 @@ pip install paddlepaddle-gpu ...@@ -61,8 +61,7 @@ pip install paddlepaddle-gpu
安装paddleslim: 安装paddleslim:
```shell ```shell
https://github.com/PaddlePaddle/PaddleSlim.git pip install paddleslim
python setup.py install
``` ```
安装paddlenlp: 安装paddlenlp:
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#### 3.1 准备环境 #### 3.1 准备环境
- python >= 3.6 - python >= 3.6
- PaddlePaddle >= 2.3 (可从[Paddle官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)下载安装) - PaddlePaddle >= 2.3 (可从[Paddle官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)下载安装)
- PaddleSlim develop版本或PaddleSlim>=2.3.0 - PaddleSlim >= 2.3
- X2Paddle develop版本 - X2Paddle develop版本
- transformers >= 4.18.0 - transformers >= 4.18.0
- PaddleNLP >= 2.3 - PaddleNLP >= 2.3
...@@ -62,8 +62,7 @@ pip install paddlepaddle-gpu ...@@ -62,8 +62,7 @@ pip install paddlepaddle-gpu
安装paddleslim: 安装paddleslim:
```shell ```shell
git clone https://github.com/PaddlePaddle/PaddleSlim.git pip install paddleslim
python setup.py install
``` ```
安装X2Paddle: 安装X2Paddle:
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#### 3.1 准备环境 #### 3.1 准备环境
- PaddlePaddle >= 2.3 (可从[Paddle官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)下载安装) - PaddlePaddle >= 2.3 (可从[Paddle官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)下载安装)
- PaddleSlim develop版本 - PaddleSlim >= 2.3
- PaddleDet >= 2.4 - PaddleDet >= 2.4
- [X2Paddle](https://github.com/PaddlePaddle/X2Paddle) >= 1.3.6 - [X2Paddle](https://github.com/PaddlePaddle/X2Paddle) >= 1.3.6
- opencv-python - opencv-python
...@@ -48,8 +48,7 @@ pip install paddlepaddle-gpu ...@@ -48,8 +48,7 @@ pip install paddlepaddle-gpu
(2)安装paddleslim: (2)安装paddleslim:
```shell ```shell
https://github.com/PaddlePaddle/PaddleSlim.git pip install paddleslim
python setup.py install
``` ```
(3)安装paddledet: (3)安装paddledet:
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
#### 3.1 准备环境 #### 3.1 准备环境
- PaddlePaddle >= 2.3 (可从[Paddle官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)下载安装) - PaddlePaddle >= 2.3 (可从[Paddle官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)下载安装)
- PaddleSlim develop版本 - PaddleSlim >= 2.3
- PaddleSeg >= 2.5 - PaddleSeg >= 2.5
安装paddlepaddle: 安装paddlepaddle:
...@@ -71,8 +71,7 @@ pip install paddlepaddle-gpu ...@@ -71,8 +71,7 @@ pip install paddlepaddle-gpu
安装paddleslim: 安装paddleslim:
```shell ```shell
https://github.com/PaddlePaddle/PaddleSlim.git pip install paddleslim
python setup.py install
``` ```
安装paddleseg 安装paddleseg
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#### 3.1 准备环境 #### 3.1 准备环境
- PaddlePaddle >= 2.3 (可从[Paddle官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)下载安装) - PaddlePaddle >= 2.3 (可从[Paddle官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)下载安装)
- PaddleSlim develop版本 - PaddleSlim >= 2.3
- [X2Paddle](https://github.com/PaddlePaddle/X2Paddle) >= 1.3.6 - [X2Paddle](https://github.com/PaddlePaddle/X2Paddle) >= 1.3.6
- opencv-python - opencv-python
...@@ -46,8 +46,7 @@ pip install paddlepaddle-gpu ...@@ -46,8 +46,7 @@ pip install paddlepaddle-gpu
(2)安装paddleslim: (2)安装paddleslim:
```shell ```shell
https://github.com/PaddlePaddle/PaddleSlim.git pip install paddleslim
python setup.py install
``` ```
(3)安装TensorFlow: (3)安装TensorFlow:
......
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
# limitations under the License. # limitations under the License.
import os import os
import pip
import platform
import logging
import pickle import pickle
import shutil import shutil
import subprocess import subprocess
...@@ -25,9 +28,12 @@ import paddle ...@@ -25,9 +28,12 @@ import paddle
from .parse_ops import get_key_from_op from .parse_ops import get_key_from_op
from .extract_features import get_data_from_tables, get_features_from_paramkey from .extract_features import get_data_from_tables, get_features_from_paramkey
from ._utils import opt_model, load_predictor, nearest_interpolate, _get_download from ._utils import opt_model, load_predictor, nearest_interpolate, _get_download
from ..common import get_logger
from ..core import GraphWrapper from ..core import GraphWrapper
__all__ = ["LatencyPredictor", "TableLatencyPredictor"] __all__ = ["LatencyPredictor", "TableLatencyPredictor"]
_logger = get_logger(__name__, level=logging.INFO)
TABLE_URL = 'https://paddlemodels.bj.bcebos.com/PaddleSlim/analysis/' TABLE_URL = 'https://paddlemodels.bj.bcebos.com/PaddleSlim/analysis/'
...@@ -71,6 +77,7 @@ class TableLatencyPredictor(LatencyPredictor): ...@@ -71,6 +77,7 @@ class TableLatencyPredictor(LatencyPredictor):
hardware_list = ['SD625', 'SD710', 'RK3288'] hardware_list = ['SD625', 'SD710', 'RK3288']
def __init__(self, table_file='SD710'): def __init__(self, table_file='SD710'):
self._check_opt_model()
self.table_file = table_file self.table_file = table_file
self.table_dict = {} self.table_dict = {}
self.hardware = None self.hardware = None
...@@ -83,6 +90,22 @@ class TableLatencyPredictor(LatencyPredictor): ...@@ -83,6 +90,22 @@ class TableLatencyPredictor(LatencyPredictor):
def add_hardware(cls, hardware): def add_hardware(cls, hardware):
cls.hardware_list.append(hardware) cls.hardware_list.append(hardware)
def _check_opt_model(self):
if platform.system().lower() == 'windows':
raise NotImplementedError(
'latency predictor does NOT support running on Windows.')
elif platform.system().lower() == 'darwin':
py_verion = platform.python_version().split('.')
if int(py_version[0]) != 3 or int(py_version[1]) != 9:
raise NotImplementedError(
'latency predictor does NOT support running on macOS when python version is not 3.9.'
)
_logger.info("pip install paddleslim-opt-tools")
out = shutil.which('paddle_lite_opt')
if out is None:
pip.main(['install', 'paddleslim-opt-tools'])
def _initial_table(self): def _initial_table(self):
if self.table_file in TableLatencyPredictor.hardware_list: if self.table_file in TableLatencyPredictor.hardware_list:
self.hardware = self.table_file self.hardware = self.table_file
......
...@@ -62,7 +62,12 @@ def predict_compressed_model(executor, ...@@ -62,7 +62,12 @@ def predict_compressed_model(executor,
model_file = os.path.join(model_dir, model_filename) model_file = os.path.join(model_dir, model_filename)
param_file = os.path.join(model_dir, params_filename) param_file = os.path.join(model_dir, params_filename)
predictor = TableLatencyPredictor(hardware) try:
predictor = TableLatencyPredictor(hardware)
except NotImplementedError:
raise NotImplementedError(
"Latency predictor cannot used on the platform: {}. That means you can not use latency predictor to select compress strategy automatically, you can set deploy_hardware to None or set compress strategy in the yaml".
format(platform.system()))
latency = predictor.predict( latency = predictor.predict(
model_file=model_file, param_file=param_file, data_type='fp32') model_file=model_file, param_file=param_file, data_type='fp32')
latency_dict.update({'origin_fp32': latency}) latency_dict.update({'origin_fp32': latency})
......
...@@ -21,7 +21,7 @@ import platform ...@@ -21,7 +21,7 @@ import platform
from setuptools import find_packages from setuptools import find_packages
from setuptools import setup from setuptools import setup
slim_version = "2.3.0" slim_version = "2.3.1"
with open('./requirements.txt') as f: with open('./requirements.txt') as f:
setup_requires = f.read().splitlines() setup_requires = f.read().splitlines()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册