Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]Add paddleslim ACT. #3457

Merged
merged 12 commits into from
Aug 28, 2023
Merged

Conversation

shiyutang
Copy link
Collaborator

PR types

New features

PR changes

Others

Description

Add paddleslim ACT function on ppliteseg as an example.

@shiyutang shiyutang changed the title Slim act [Feature]Add paddleslim ACT. Aug 16, 2023
paddleseg/cvlibs/config.py Outdated Show resolved Hide resolved
deploy/slim/act/run.py Outdated Show resolved Hide resolved
deploy/slim/act/run.py Outdated Show resolved Hide resolved
#### 3.1 准备环境

- PaddlePaddle >= 2.4 (可从[Paddle官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)下载安装)
- PaddleSlim >= 2.4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

paddle和slim都是2.5,套件使用develop,pr合入develop,后cherry-pick到最新分支

Copy link
Collaborator

@juncaipeng juncaipeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

整个方案可以了;代码参考谷歌编程规范,很多地方再优化下;文档说清楚点。

deploy/slim/act/run_seg.py Outdated Show resolved Hide resolved
deploy/slim/act/run_seg.py Outdated Show resolved Hide resolved
deploy/slim/act/run_seg.py Outdated Show resolved Hide resolved
deploy/slim/act/run_seg.py Show resolved Hide resolved
deploy/slim/act/run_seg.py Outdated Show resolved Hide resolved
config['params_filename']) # get the name of forward input
train_dataloader = reader_wrapper(train_loader, input_name)

rank_id = paddle.distributed.get_rank()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

重复定义

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

| 模型 | 策略 | Total IoU (%) | CPU耗时(ms)<br>thread=10<br>mkldnn=on| Nvidia GPU耗时(ms)<br>TRT=off| 配置文件 | Inference模型 |
|:-----:|:-----:|:----------:|:---------:| :------:|:------:|:------:|
| OCRNet_HRNetW48 |Baseline |todo| todo| todo|todo|todo|
| OCRNet_HRNetW48 | 量化训练QAT |todo| todo| todo|todo|todo|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

只有量化训练QAT 还是 量化训练QAT结合蒸馏?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经替换成量化蒸馏训练


## 2.Benchmark

| 模型 | 策略 | Total IoU (%) | CPU耗时(ms)<br>thread=10<br>mkldnn=on| Nvidia GPU耗时(ms)<br>TRT=off| 配置文件 | Inference模型 |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个表格需要展示压缩前后的精度和推理速度,现在表头的字段不对啊

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对于不同配置分成了两行来对比,一行是baseline,一行QAT,后续增加不同的配置可以增加多行,方便不同配置之间的对比。


- 示例数据集: cityscapes数据集的一个子集,用于快速跑通压缩和推理流程,不能用该数据集复现 benchmark 表中的压缩效果。[下载链接](https://bj.bcebos.com/v1/paddle-slim-models/data/mini_cityscapes/mini_cityscapes.tar)

准备好数据后,需要放入到`deploy/slim/act`目录下。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

怎么放? 整个文档需要人家可以执行复现,比如文档甩给qa可以帮你测试完成,可以再整体优化下

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的~

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经修改内容,并已经向QA提测。

@@ -0,0 +1,319 @@
# Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文件名称改成test_seg.py

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return miou


def reader_wrapper(reader, input_name):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

开发者不太清楚这个wrapper的作用,需要说明act对dataset的要求,这部分还挺关键

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

act对dataset的要求和套件一致,因为数据的配置使用的seg的配置文件,通过segbuilder加载之后,使用dataloader获取数据。


### 3. 量化蒸馏训练精度很低?
![2d916558811eb5f1bbb388025ddda21c](https://github.com/PaddlePaddle/PaddleOCR/assets/34859558/cc9bcc26-1568-4ab9-96f3-ff181486637c)
**A**:去除量化训练的输出结果,重新运行一次,这是由于网络训练到局部极值点导致。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要空行,预览错误

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -0,0 +1 @@
请参考[语义分割模型自动压缩示例](../../../../deploy/slim/act/readme.md)了解更多基于PaddleSeg接入ACT的方式。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在seg的首页readme里面,可以加下Auto Compression,链接到这里面来

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@shiyutang shiyutang merged commit 88cbff8 into PaddlePaddle:develop Aug 28, 2023
@shiyutang shiyutang deleted the slim_act branch August 28, 2023 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants