文件最后提交记录最后更新时间
新建 WeNet4 年前
!4893 [批量整改][推理] 代码公网地址整改 * update ACL_PyTorch/contrib/cv/classfication/Inception_V4/inceptionv4_p… * fix pub address 2 年前
[苏州大学][高校贡献][PyTorch离线推理][WeNet] 4 年前
【BugFix】【Pytorch离线推理】ACL接口兼容性修改 4 年前
[苏州大学][高校贡献][PyTorch离线推理][WeNet] 4 年前
[苏州大学][高校贡献][PyTorch离线推理][WeNet] 4 年前
update ACL_PyTorch/contrib/audio/WeNet/export_onnx.py. 4 年前
[苏州大学][高校贡献][PyTorch离线推理][WeNet] 4 年前
[苏州大学][高校贡献][PyTorch离线推理][WeNet] 修改源码,测试gpu性能4 年前
!7376 optimize public_address_statement.md Merge pull request !7376 from 王凯宇/master 8 个月前
[苏州大学][高校贡献][PyTorch离线推理][WeNet] 4 年前
!4893 [批量整改][推理] 代码公网地址整改 * update ACL_PyTorch/contrib/cv/classfication/Inception_V4/inceptionv4_p… * fix pub address 2 年前
update ACL_PyTorch/contrib/audio/WeNet/slice_helper.py. 4 年前
[苏州大学][高校贡献][PyTorch离线推理][WeNet] 4 年前
update ACL_PyTorch/contrib/audio/WeNet/static_decoder.sh. 4 年前
update ACL_PyTorch/contrib/audio/WeNet/static_encoder.sh. 4 年前
!4893 [批量整改][推理] 代码公网地址整改 * update ACL_PyTorch/contrib/cv/classfication/Inception_V4/inceptionv4_p… * fix pub address 2 年前
重命名 ACL_PyTorch/contrib/audio/WeNet/export_onnx.diff 为 ACL_PyTorch/contrib/audio/WeNet/wenet_onnx.diff4 年前
README.md

Wenet模型PyTorch离线推理指导

1 环境准备

  1. 安装必要的依赖,测试环境可能已经安装其中的一些不同版本的库了,故手动测试时不推荐使用该命令安装
pip3 install -r requirements.txt  
  1. 获取,修改与安装开源模型代码
git clone https://github.com/wenet-e2e/wenet.git
cd wenet
git reset 9c4e305bcc24a06932f6a65c8147429d8406cc63 --hard
  1. 下载网络权重文件并导出onnx

下载链接:http://mobvoi-speech-public.ufile.ucloud.cn/public/wenet/aishell/20210601_u2pp_conformer_exp.tar.gz下载压缩文件,将文件解压,将文件夹内的文件放置到wenet/examples/aishell/s0/exp/conformer_u2文件夹下,若没有该文件夹,则创建该文件夹

将提供的diff文件放到wenet根目录下 patch -p1 < wenet_onnx.diff文件适配导出onnx的代码 将提供的export_onnx.py、static.py文件放到wenet/wenet/bin/目录下 将提供的slice_helper.py, acl_net.py文件放到wenet/wenet/transformer文件夹下 将提供的sh脚本文件(除了static_encoder.sh和static_decoder.sh)放到wenet/examples/aishell/s0/目录下 运行bash export_onnx.sh exp/conformer_u2/train.yaml exp/conformer_u2/final.pt导出onnx文件在当前目录下的onnx文件夹下

  1. 修改onnx

首先使用改图工具om_gener改图,该工具链接为https://gitee.com/liurf_hw/om_gener,安装之后使用以下命令修改脚本,

python3 adaptdecoder.py生成decoder_final.onnx

python3 adaptnoflashencoder.py生成no_flash_encoder_revise.onnx

  1. 数据集下载:

    在wenet/examples/aishell/s0/文件夹下运行bash run.sh --stage -1 –stop_stage -1下载数据集

    运行bash run.sh --stage 0 --stop_stage 0处理数据集

    运行bash run.sh --stage 1 --stop_stage 1处理数据集

    运行bash run.sh --stage 2 --stop_stage 2处理数据集

    运行bash run.sh --stage 3 --stop_stage 3处理数据集

2 离线推理

onnx转om: 将static_encoder.sh和static_decoder.sh放到s0/onnx文件下,请以实际安装环境配置环境变量。

source /usr/local/Ascend/ascend-toolkit/set_env.sh
bash static_encoder.sh
bash static_decoder.sh

精度测试:

首先export ASCEND_GLOBAL_LOG_LEVEL=3,指定acc.diff中self.encoder_ascend, self.decoder_ascend加载的文件为静态转出的encoder,decoder模型路径

git checkout .
patch -p1 < acc.diff
cd examples/aishell/s0/
bash static.sh

性能:在wenet/examples/aishell/s0/exp/conformer/test_attention_rescoring/text文件最后一行有fps性能数据

gpu性能测试:

git checkout .
patch -p1 < gpu_fps.diff
cd examples/aishell/s0/

// 运行之前修改run.sh中average_checkpoint为false, decode_modes修改为attention_rescoring 修改stage5中ctc_weight=0.3 reverse_weight=0.3
bash run.sh --stage 5 --stop_stage 5

在wenet/examples/aishell/s0/exp/conformer/test_attention_rescoring/text文件最后一行有fps性能数据

公网地址说明

代码涉及公网地址参考 public_address_statement.md