Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
29eb61ec
P
PaddleSlim
项目概览
PaddlePaddle
/
PaddleSlim
大约 1 年 前同步成功
通知
51
Star
1434
Fork
344
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
53
列表
看板
标记
里程碑
合并请求
16
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleSlim
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
53
Issue
53
列表
看板
标记
里程碑
合并请求
16
合并请求
16
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
29eb61ec
编写于
7月 06, 2022
作者:
C
ceci3
提交者:
GitHub
7月 06, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cancel opt_model in requirement.txt (#1261)
上级
8c23dc93
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
58 addition
and
25 deletion
+58
-25
example/auto_compression/README.md
example/auto_compression/README.md
+15
-2
example/auto_compression/detection/README.md
example/auto_compression/detection/README.md
+2
-3
example/auto_compression/image_classification/README.md
example/auto_compression/image_classification/README.md
+2
-3
example/auto_compression/nlp/README.md
example/auto_compression/nlp/README.md
+2
-3
example/auto_compression/pytorch_huggingface/README.md
example/auto_compression/pytorch_huggingface/README.md
+2
-3
example/auto_compression/pytorch_yolov5/README.md
example/auto_compression/pytorch_yolov5/README.md
+2
-3
example/auto_compression/semantic_segmentation/README.md
example/auto_compression/semantic_segmentation/README.md
+2
-3
example/auto_compression/tensorflow_mobilenet/README.md
example/auto_compression/tensorflow_mobilenet/README.md
+2
-3
paddleslim/analysis/latency_predictor.py
paddleslim/analysis/latency_predictor.py
+23
-0
paddleslim/auto_compression/utils/predict.py
paddleslim/auto_compression/utils/predict.py
+6
-1
requirements.txt
requirements.txt
+0
-1
未找到文件。
example/auto_compression/README.md
浏览文件 @
29eb61ec
...
...
@@ -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
)
下载安装)
-
安装PaddleSlim develop版本
-
安装PaddlePaddle >= 2.3 (从
[
Paddle官网
](
https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html
)
下载安装)
-
安装PaddleSlim >=2.3
(1)安装paddlepaddle:
```
shell
# CPU
pip
install
paddlepaddle
# GPU
pip
install
paddlepaddle-gpu
```
(2)安装paddleslim:
```
shell
pip
install
paddleslim
```
## 快速上手
...
...
example/auto_compression/detection/README.md
浏览文件 @
29eb61ec
...
...
@@ -32,7 +32,7 @@
#### 3.1 准备环境
-
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
-
opencv-python
...
...
@@ -46,8 +46,7 @@ pip install paddlepaddle-gpu
安装paddleslim:
```
shell
https://github.com/PaddlePaddle/PaddleSlim.git
python setup.py
install
pip
install
paddleslim
```
安装paddledet:
...
...
example/auto_compression/image_classification/README.md
浏览文件 @
29eb61ec
...
...
@@ -56,7 +56,7 @@
-
python >= 3.6
-
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:
```
shell
...
...
@@ -68,8 +68,7 @@ pip install paddlepaddle-gpu
安装paddleslim:
```
shell
https://github.com/PaddlePaddle/PaddleSlim.git
python setup.py
install
pip
install
paddleslim
```
#### 3.2 准备数据集
...
...
example/auto_compression/nlp/README.md
浏览文件 @
29eb61ec
...
...
@@ -48,7 +48,7 @@
#### 3.1 准备环境
-
python >= 3.6
-
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
安装paddlepaddle:
...
...
@@ -61,8 +61,7 @@ pip install paddlepaddle-gpu
安装paddleslim:
```
shell
https://github.com/PaddlePaddle/PaddleSlim.git
python setup.py
install
pip
install
paddleslim
```
安装paddlenlp:
...
...
example/auto_compression/pytorch_huggingface/README.md
浏览文件 @
29eb61ec
...
...
@@ -44,7 +44,7 @@
#### 3.1 准备环境
-
python >= 3.6
-
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版本
-
transformers >= 4.18.0
-
PaddleNLP >= 2.3
...
...
@@ -62,8 +62,7 @@ pip install paddlepaddle-gpu
安装paddleslim:
```
shell
git clone https://github.com/PaddlePaddle/PaddleSlim.git
python setup.py
install
pip
install
paddleslim
```
安装X2Paddle:
...
...
example/auto_compression/pytorch_yolov5/README.md
浏览文件 @
29eb61ec
...
...
@@ -33,7 +33,7 @@
#### 3.1 准备环境
-
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
-
[
X2Paddle
](
https://github.com/PaddlePaddle/X2Paddle
)
>= 1.3.6
-
opencv-python
...
...
@@ -48,8 +48,7 @@ pip install paddlepaddle-gpu
(2)安装paddleslim:
```
shell
https://github.com/PaddlePaddle/PaddleSlim.git
python setup.py
install
pip
install
paddleslim
```
(3)安装paddledet:
...
...
example/auto_compression/semantic_segmentation/README.md
浏览文件 @
29eb61ec
...
...
@@ -58,7 +58,7 @@
#### 3.1 准备环境
-
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
安装paddlepaddle:
...
...
@@ -71,8 +71,7 @@ pip install paddlepaddle-gpu
安装paddleslim:
```
shell
https://github.com/PaddlePaddle/PaddleSlim.git
python setup.py
install
pip
install
paddleslim
```
安装paddleseg
...
...
example/auto_compression/tensorflow_mobilenet/README.md
浏览文件 @
29eb61ec
...
...
@@ -32,7 +32,7 @@
#### 3.1 准备环境
-
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
-
opencv-python
...
...
@@ -46,8 +46,7 @@ pip install paddlepaddle-gpu
(2)安装paddleslim:
```
shell
https://github.com/PaddlePaddle/PaddleSlim.git
python setup.py
install
pip
install
paddleslim
```
(3)安装TensorFlow:
...
...
paddleslim/analysis/latency_predictor.py
浏览文件 @
29eb61ec
...
...
@@ -15,6 +15,9 @@
# limitations under the License.
import
os
import
pip
import
platform
import
logging
import
pickle
import
shutil
import
subprocess
...
...
@@ -25,9 +28,12 @@ import paddle
from
.parse_ops
import
get_key_from_op
from
.extract_features
import
get_data_from_tables
,
get_features_from_paramkey
from
._utils
import
opt_model
,
load_predictor
,
nearest_interpolate
,
_get_download
from
..common
import
get_logger
from
..core
import
GraphWrapper
__all__
=
[
"LatencyPredictor"
,
"TableLatencyPredictor"
]
_logger
=
get_logger
(
__name__
,
level
=
logging
.
INFO
)
TABLE_URL
=
'https://paddlemodels.bj.bcebos.com/PaddleSlim/analysis/'
...
...
@@ -71,6 +77,7 @@ class TableLatencyPredictor(LatencyPredictor):
hardware_list
=
[
'SD625'
,
'SD710'
,
'RK3288'
]
def
__init__
(
self
,
table_file
=
'SD710'
):
self
.
_check_opt_model
()
self
.
table_file
=
table_file
self
.
table_dict
=
{}
self
.
hardware
=
None
...
...
@@ -83,6 +90,22 @@ class TableLatencyPredictor(LatencyPredictor):
def
add_hardware
(
cls
,
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
):
if
self
.
table_file
in
TableLatencyPredictor
.
hardware_list
:
self
.
hardware
=
self
.
table_file
...
...
paddleslim/auto_compression/utils/predict.py
浏览文件 @
29eb61ec
...
...
@@ -62,7 +62,12 @@ def predict_compressed_model(executor,
model_file
=
os
.
path
.
join
(
model_dir
,
model_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
(
model_file
=
model_file
,
param_file
=
param_file
,
data_type
=
'fp32'
)
latency_dict
.
update
({
'origin_fp32'
:
latency
})
...
...
requirements.txt
浏览文件 @
29eb61ec
...
...
@@ -6,4 +6,3 @@ pillow
pyyaml
scikit-learn
smac
paddleslim-opt-tools
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录