未验证 提交 80184c47 编写于 作者: Z zhouzj 提交者: GitHub

Fix Auto_seg's demo (#1124)

* Add dataset download link.

* Fix some bugs.

* Fix some bugs.

* Fix docs.
上级 66c1680c
...@@ -56,7 +56,7 @@ Prune: ...@@ -56,7 +56,7 @@ Prune:
# pruned_ratio: 裁剪比例 # pruned_ratio: 裁剪比例
pruned_ratio: 0.25 pruned_ratio: 0.25
# prune_params_name: 需要裁剪的参数名字 # prune_params_name: 需要裁剪的参数名字
prune_params_name: prune_params_name:
- conv1_weights - conv1_weights
# criterion: 评估一个卷积层内通道重要性所参考的指标 # criterion: 评估一个卷积层内通道重要性所参考的指标
criterion: l1_norm criterion: l1_norm
...@@ -79,12 +79,12 @@ UnstructurePrune: ...@@ -79,12 +79,12 @@ UnstructurePrune:
threshold: 0.001 threshold: 0.001
# gmp_config: 传入额外的训练超参用以指导GMP训练过程 # gmp_config: 传入额外的训练超参用以指导GMP训练过程
gmp_config: gmp_config:
- stable_iterations: 0 stable_iterations: 0
- pruning_iterations: 4500 # total_iters * 0.4~0.45 pruning_iterations: 4500 # total_iters * 0.4~0.45
- tunning_iterations: 4500 # total_iters * 0.4~0.45 tunning_iterations: 4500 # total_iters * 0.4~0.45
- resume_iteration: -1 resume_iteration: -1
- pruning_steps: 100 pruning_steps: 100
- initial_ratio: 0.15 initial_ratio: 0.15
# prune_params_type: 用以指定哪些类型的参数参与稀疏。 # prune_params_type: 用以指定哪些类型的参数参与稀疏。
prune_params_type: conv1x1_only prune_params_type: conv1x1_only
# local_sparsity: 剪裁比例(ratio)应用的范围 # local_sparsity: 剪裁比例(ratio)应用的范围
......
...@@ -61,7 +61,7 @@ pip install paddleseg ...@@ -61,7 +61,7 @@ pip install paddleseg
#### 3.2 准备数据集 #### 3.2 准备数据集
开发者可下载开源数据集或自定义语义分割数据集,例如PP-HumanSeg-Lite模型中使用的语义分割数据集[PP-HumanSeg14K](https://github.com/PaddlePaddle/PaddleSeg/blob/release/2.5/contrib/PP-HumanSeg/paper.md#pp-humanseg14k-a-large-scale-teleconferencing-video-dataset)可从官方渠道下载。 开发者可下载开源数据集 ([AIsegment](https://github.com/aisegmentcn/matting_human_datasets)) 或自定义语义分割数据集,例如PP-HumanSeg-Lite模型中使用的语义分割数据集[PP-HumanSeg14K](https://github.com/PaddlePaddle/PaddleSeg/blob/release/2.5/contrib/PP-HumanSeg/paper.md#pp-humanseg14k-a-large-scale-teleconferencing-video-dataset)可从官方渠道下载。
如果是自定义数据,请参考[PaddleSeg数据准备文档](https://github.com/PaddlePaddle/PaddleSeg/blob/release/2.5/docs/data/marker/marker_cn.md)来检查对齐数据格式即可。 如果是自定义数据,请参考[PaddleSeg数据准备文档](https://github.com/PaddlePaddle/PaddleSeg/blob/release/2.5/docs/data/marker/marker_cn.md)来检查对齐数据格式即可。
...@@ -74,7 +74,7 @@ pip install paddleseg ...@@ -74,7 +74,7 @@ pip install paddleseg
- 如果想快速体验,可直接下载PP-HumanSeg-Lite 的预测模型: - 如果想快速体验,可直接下载PP-HumanSeg-Lite 的预测模型:
```shell ```shell
wget https://paddleseg.bj.bcebos.com/dygraph/ppseg/ppseg_lite_portrait_398x224_with_softmax.tar.gz wget https://bj.bcebos.com/v1/paddlemodels/PaddleSlim/analysis/ppseg_lite_portrait_398x224_with_softmax.tar.gz
tar -xzf ppseg_lite_portrait_398x224_with_softmax.tar.gz tar -xzf ppseg_lite_portrait_398x224_with_softmax.tar.gz
``` ```
...@@ -87,6 +87,7 @@ tar -xzf ppseg_lite_portrait_398x224_with_softmax.tar.gz ...@@ -87,6 +87,7 @@ tar -xzf ppseg_lite_portrait_398x224_with_softmax.tar.gz
当只设置训练参数,并传入``deploy_hardware``字段时,将自动搜索压缩策略进行压缩。以骁龙710(SD710)为部署硬件,进行自动压缩的运行命令如下: 当只设置训练参数,并传入``deploy_hardware``字段时,将自动搜索压缩策略进行压缩。以骁龙710(SD710)为部署硬件,进行自动压缩的运行命令如下:
```shell ```shell
# 单卡启动
export CUDA_VISIBLE_DEVICES=0 export CUDA_VISIBLE_DEVICES=0
python run.py \ python run.py \
--model_dir='./ppseg_lite_portrait_398x224_with_softmax' \ --model_dir='./ppseg_lite_portrait_398x224_with_softmax' \
...@@ -95,9 +96,20 @@ python run.py \ ...@@ -95,9 +96,20 @@ python run.py \
--save_dir='./save_model' \ --save_dir='./save_model' \
--config_path='configs/pp_humanseg_auto.yaml' \ --config_path='configs/pp_humanseg_auto.yaml' \
--deploy_hardware='SD710' --deploy_hardware='SD710'
# 多卡启动
export CUDA_VISIBLE_DEVICES=0,1
python -m paddle.distributed.launch run.py \
--model_dir='./ppseg_lite_portrait_398x224_with_softmax' \
--model_filename='model.pdmodel' \
--params_filename='model.pdiparams' \
--save_dir='./save_model' \
--config_path='configs/pp_humanseg_auto.yaml'
--deploy_hardware='SD710'
``` ```
- 自行配置稀疏参数进行非结构化稀疏和蒸馏训练,配置参数含义详见[自动压缩超参文档](https://github.com/PaddlePaddle/PaddleSlim/blob/27dafe1c722476f1b16879f7045e9215b6f37559/demo/auto_compression/hyperparameter_tutorial.md)。具体命令如下所示: - 自行配置稀疏参数进行非结构化稀疏和蒸馏训练,配置参数含义详见[自动压缩超参文档](https://github.com/PaddlePaddle/PaddleSlim/blob/27dafe1c722476f1b16879f7045e9215b6f37559/demo/auto_compression/hyperparameter_tutorial.md)。具体命令如下所示:
```shell ```shell
# 单卡启动
export CUDA_VISIBLE_DEVICES=0 export CUDA_VISIBLE_DEVICES=0
python run.py \ python run.py \
--model_dir='./ppseg_lite_portrait_398x224_with_softmax' \ --model_dir='./ppseg_lite_portrait_398x224_with_softmax' \
...@@ -105,10 +117,20 @@ python run.py \ ...@@ -105,10 +117,20 @@ python run.py \
--params_filename='model.pdiparams' \ --params_filename='model.pdiparams' \
--save_dir='./save_model' \ --save_dir='./save_model' \
--config_path='configs/pp_humanseg_sparse_dis.yaml' --config_path='configs/pp_humanseg_sparse_dis.yaml'
# 多卡启动
export CUDA_VISIBLE_DEVICES=0,1
python -m paddle.distributed.launch run.py \
--model_dir='./ppseg_lite_portrait_398x224_with_softmax' \
--model_filename='model.pdmodel' \
--params_filename='model.pdiparams' \
--save_dir='./save_model' \
--config_path='configs/pp_humanseg_sparse_dis.yaml'
``` ```
- 自行配置量化参数进行量化和蒸馏训练,配置参数含义详见[自动压缩超参文档](https://github.com/PaddlePaddle/PaddleSlim/blob/27dafe1c722476f1b16879f7045e9215b6f37559/demo/auto_compression/hyperparameter_tutorial.md)。具体命令如下所示: - 自行配置量化参数进行量化和蒸馏训练,配置参数含义详见[自动压缩超参文档](https://github.com/PaddlePaddle/PaddleSlim/blob/27dafe1c722476f1b16879f7045e9215b6f37559/demo/auto_compression/hyperparameter_tutorial.md)。具体命令如下所示:
```shell ```shell
# 单卡启动
export CUDA_VISIBLE_DEVICES=0 export CUDA_VISIBLE_DEVICES=0
python run.py \ python run.py \
--model_dir='./ppseg_lite_portrait_398x224_with_softmax' \ --model_dir='./ppseg_lite_portrait_398x224_with_softmax' \
...@@ -116,6 +138,15 @@ python run.py \ ...@@ -116,6 +138,15 @@ python run.py \
--params_filename='model.pdiparams' \ --params_filename='model.pdiparams' \
--save_dir='./save_model' \ --save_dir='./save_model' \
--config_path='configs/pp_humanseg_quant_dis.yaml' --config_path='configs/pp_humanseg_quant_dis.yaml'
# 多卡启动
export CUDA_VISIBLE_DEVICES=0,1
python -m paddle.distributed.launch run.py \
--model_dir='./ppseg_lite_portrait_398x224_with_softmax' \
--model_filename='model.pdmodel' \
--params_filename='model.pdiparams' \
--save_dir='./save_model' \
--config_path='configs/pp_humanseg_quant_dis.yaml'
``` ```
压缩完成后会在`save_dir`中产出压缩好的预测模型,可直接预测部署。 压缩完成后会在`save_dir`中产出压缩好的预测模型,可直接预测部署。
......
...@@ -27,7 +27,10 @@ UnstructurePrune: ...@@ -27,7 +27,10 @@ UnstructurePrune:
TrainConfig: TrainConfig:
epochs: 14 epochs: 14
eval_iter: 400 eval_iter: 400
learning_rate: 5.0e-03 learning_rate:
type: PiecewiseDecay
boundaries: [4500]
values: [0.005, 0.0005]
optim_args: optim_args:
weight_decay: 0.0005 weight_decay: 0.0005
optimizer: SGD optimizer: SGD
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册