ONNX 模型库
返回模型

说明文档

简介

本模型转换自 https://modelscope.cn/models/iic/punc_ct-transformer_zh-cn-common-vocab272727-pytorch/summary

生成 ONNX 模型的命令如下:

pip install funasr modelscope
pip install kaldi-native-fbank torchaudio onnx onnxruntime

mkdir -p /tmp/models
cd /tmp/models

git clone https://www.modelscope.cn/iic/punc_ct-transformer_zh-cn-common-vocab272727-pytorch.git
cd punc_ct-transformer_zh-cn-common-vocab272727-pytorch
git lfs pull --include model.pt

cd /tmp
git clone https://github.com/alibaba-damo-academy/FunASR
cd FunASR/runtime/python/onnxruntime

cat >export-onnx.py <<EOF

from funasr_onnx import CT_Transformer
model_dir = "/tmp/punc_ct-transformer_zh-cn-common-vocab272727-pytorch" # model = CT_Transformer(model_dir, quantize=True) model = CT_Transformer(model_dir)
EOF

chmod +x export-onnx.py

./export-onnx.py

导出的 model.onnx 文件位于 /tmp/models/punc_ct-transformer_zh-cn-common-vocab272727-pytorch 目录中。

现在可以使用本仓库中的 ./add-model-metadata.py 为生成的 model.onnx 添加元数据。

你可以使用

from onnxruntime.quantization import QuantType, quantize_dynamic

quantize_dynamic(
  model_input="./model.onnx",
  model_output="./model.int8.onnx",
  weight_type=QuantType.QUInt8,
)

来获取 int8 量化模型

-rw-r--r--  1 fangjun  staff    72M Jun 18 10:33 model.int8.onnx
-rw-r--r--  1 fangjun  staff   281M Apr 12  2024 model.onnx

anchor-flux/punct-ct-transformer-zh

作者 anchor-flux

↓ 21 ♥ 0

创建时间: 2026-03-05 20:32:25+00:00

更新时间: 2026-03-05 20:32:55+00:00

在 Hugging Face 上查看

文件 (7)

.gitattributes
README.md
config.json
config.yaml
model.onnx ONNX
tokens.json
vocab.txt