From 30433b58d68b93f85e61f304af32e6c7c8ef1f11 Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期二, 28 三月 2023 20:23:01 +0800
Subject: [PATCH] export
---
funasr/export/test/__init__.py | 0
funasr/export/test/test_onnx_vad.py | 26 ++++++++++++++++++++++++++
funasr/export/test/test_torchscripts.py | 0
funasr/export/test/test_onnx.py | 0
4 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/funasr/export/test/__init__.py b/funasr/export/test/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/funasr/export/test/__init__.py
diff --git a/funasr/export/test_onnx.py b/funasr/export/test/test_onnx.py
similarity index 100%
rename from funasr/export/test_onnx.py
rename to funasr/export/test/test_onnx.py
diff --git a/funasr/export/test/test_onnx_vad.py b/funasr/export/test/test_onnx_vad.py
new file mode 100644
index 0000000..12f058f
--- /dev/null
+++ b/funasr/export/test/test_onnx_vad.py
@@ -0,0 +1,26 @@
+import onnxruntime
+import numpy as np
+
+
+if __name__ == '__main__':
+ onnx_path = "/mnt/workspace/export/damo/speech_fsmn_vad_zh-cn-16k-common-pytorch/model.onnx"
+ sess = onnxruntime.InferenceSession(onnx_path)
+ input_name = [nd.name for nd in sess.get_inputs()]
+ output_name = [nd.name for nd in sess.get_outputs()]
+
+ def _get_feed_dict(feats_length):
+
+ return {'speech': np.random.rand(1, feats_length, 400).astype(np.float32),
+ 'in_cache0': np.random.rand(1, 128, 19, 1).astype(np.float32),
+ 'in_cache1': np.random.rand(1, 128, 19, 1).astype(np.float32),
+ 'in_cache2': np.random.rand(1, 128, 19, 1).astype(np.float32),
+ 'in_cache3': np.random.rand(1, 128, 19, 1).astype(np.float32),
+ }
+
+ def _run(feed_dict):
+ output = sess.run(output_name, input_feed=feed_dict)
+ for name, value in zip(output_name, output):
+ print('{}: {}'.format(name, value.shape))
+
+ _run(_get_feed_dict(100))
+ _run(_get_feed_dict(200))
\ No newline at end of file
diff --git a/funasr/export/test_torchscripts.py b/funasr/export/test/test_torchscripts.py
similarity index 100%
rename from funasr/export/test_torchscripts.py
rename to funasr/export/test/test_torchscripts.py
--
Gitblit v1.9.1