Support onnxruntime 1.18.0 (#906)

This commit is contained in:
Fangjun Kuang
2024-07-10 17:05:26 +08:00
committed by GitHub
parent 9e446b8501
commit dd0ff2ca06
107 changed files with 644 additions and 601 deletions

View File

@@ -67,7 +67,7 @@ def get_2nd_models():
""",
),
Model(
model_name="sherpa-onnx-paraformer-zh-2023-03-28",
model_name="sherpa-onnx-paraformer-zh-2023-09-14",
idx=0,
lang="zh",
short_name="paraformer",
@@ -270,7 +270,7 @@ def get_models():
combinations = [
(
"sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23",
"sherpa-onnx-paraformer-zh-2023-03-28",
"sherpa-onnx-paraformer-zh-2023-09-14",
),
(
"sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23",

View File

@@ -69,7 +69,7 @@ def get_models():
""",
),
Model(
model_name="sherpa-onnx-paraformer-zh-2023-03-28",
model_name="sherpa-onnx-paraformer-zh-2023-09-14",
idx=0,
lang="zh",
short_name="paraformer",

View File

@@ -6,7 +6,7 @@ set -ex
function install_dependencies() {
pip install -qq torch==2.1.0+cpu torchaudio==2.1.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
pip install -qq onnx onnxruntime==1.17.1
pip install -qq onnx onnxruntime==1.18.0
pip install -r ./requirements.txt
}

View File

@@ -17,7 +17,7 @@ topics:
- voice-activity-detection
# remember to change the version in ../sherpa_onnx_macos/macos/sherpa_onnx.podspec
version: 1.10.12
version: 1.10.13
homepage: https://github.com/k2-fsa/sherpa-onnx

View File

@@ -36,7 +36,7 @@ def get_dict():
def process_linux(s, rid):
libs = [
"libonnxruntime.so.1.17.1",
"libonnxruntime.so",
"libsherpa-onnx-c-api.so",
]
prefix = f"{src_dir}/linux-{rid}/"
@@ -56,7 +56,7 @@ def process_linux(s, rid):
def process_macos(s, rid):
libs = [
"libonnxruntime.1.17.1.dylib",
"libonnxruntime.1.18.0.dylib",
"libsherpa-onnx-c-api.dylib",
]
prefix = f"{src_dir}/macos-{rid}/"

View File

@@ -32,10 +32,6 @@ function linux() {
cp -v sherpa_onnx/lib/*.so* $dst
pushd $dst
cp -v libonnxruntime.so.1.17.1 libonnxruntime.so
popd
cd ..
rm -rf t
@@ -48,10 +44,6 @@ function linux() {
cp -v sherpa_onnx/lib/*.so* $dst
pushd $dst
cp -v libonnxruntime.so.1.17.1 libonnxruntime.so
popd
cd ..
rm -rf t
@@ -64,10 +56,6 @@ function linux() {
cp -v sherpa_onnx/lib/*.so* $dst
pushd $dst
cp -v libonnxruntime.so.1.17.1 libonnxruntime.so
popd
cd ..
rm -rf t
@@ -102,7 +90,7 @@ function osx() {
cp -v sherpa_onnx/lib/*.dylib $dst/
pushd $dst
cp -v libonnxruntime.1.17.1.dylib libonnxruntime.dylib
cp -v libonnxruntime.1.18.0.dylib libonnxruntime.dylib
popd
cd ..
@@ -120,7 +108,7 @@ function osx() {
cp -v sherpa_onnx/lib/*.dylib $dst/
pushd $dst
cp -v libonnxruntime.1.17.1.dylib libonnxruntime.dylib
cp -v libonnxruntime.1.18.0.dylib libonnxruntime.dylib
popd
cd ..

View File

@@ -28,11 +28,17 @@ def add_meta_data(filename: str, meta_data: Dict[str, str]):
Key-value pairs.
"""
model = onnx.load(filename)
while len(model.metadata_props):
model.metadata_props.pop()
for key, value in meta_data.items():
meta = model.metadata_props.add()
meta.key = key
meta.value = str(value)
# model = onnx.version_converter.convert_version(model, 21)
onnx.save(model, filename)

View File

@@ -32,11 +32,17 @@ def add_meta_data(filename: str, meta_data: Dict[str, str]):
Key-value pairs.
"""
model = onnx.load(filename)
while len(model.metadata_props):
model.metadata_props.pop()
for key, value in meta_data.items():
meta = model.metadata_props.add()
meta.key = key
meta.value = str(value)
# model = onnx.version_converter.convert_version(model, 21)
onnx.save(model, filename)
@@ -87,6 +93,7 @@ def main():
x = torch.rand(N, T, C, dtype=torch.float)
x_lens = torch.full((N,), fill_value=T, dtype=torch.int64)
# https://github.com/pytorch/pytorch/issues/114801
opset_version = 13
onnx_model = torch.jit.script(onnx_model)
torch.onnx.export(

View File

@@ -9,10 +9,12 @@
set -ex
export PYTHONPATH=/tmp/wenet:$PYTHONPATH
function install_dependencies() {
pip install soundfile
pip install torch==2.1.0+cpu torchaudio==2.1.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
pip install k2==1.24.4.dev20231022+cpu.torch2.1.0 -f https://k2-fsa.github.io/k2/cpu.html
pip install torch==2.3.1+cpu torchaudio==2.3.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
pip install k2==1.24.4.dev20240606+cpu.torch2.3.1 -f https://k2-fsa.github.io/k2/cpu.html
pip install onnxruntime onnx kaldi-native-fbank pyyaml
@@ -31,7 +33,11 @@ function install_dependencies() {
cp -a ./wenet/wenet/ctl_model $wenet_dir
fi
rm -rf wenet
if [ ! -d $wenet_dir/finetune ]; then
cp -av ./wenet/wenet/finetune $wenet_dir/
fi
mv wenet /tmp
}
function aishell() {