k2-fsa / sherpa-onnx

Speech-to-text, text-to-speech, speaker diarization, and VAD using next-gen Kaldi with onnxruntime without Internet connection. Support embedded systems, Android, iOS, Raspberry Pi, RISC-V, x86_64 servers, websocket server/client, C/C++, Python, Kotlin, C#, Go, NodeJS, Java, Swift, Dart, JavaScript, Flutter, Object Pascal, Lazarus, Rust
https://k2-fsa.github.io/sherpa/onnx/index.html
Apache License 2.0
3.69k stars 428 forks source link

python推理zipformer的onnx模型提示缺少输入 #1551

Closed 2217895330 closed 1 week ago

2217895330 commented 1 week ago

我使用python推理zipformer的onnx模型进行验证时提示:Required inputs (['cached_key_0', 'cached_nonlin_attn_0', 'cached_val1_0', 'cached_val2_0', 'cached_conv1_0', 'cached_conv2_0', 'cached_key_1'......are missing from input feed (['x']). 请问这个需要怎么解决呢?

csukuangfj commented 1 week ago

信息太有限了,我们无法猜到你做了什么,没法帮助你

2217895330 commented 1 week ago

我想简单测试下zipformer的encoder部分onnx模型的效果,用了以下代码: input_data = np.random.rand(1, 45,80).astype(np.float32) ssion = onnxruntime.InferenceSession('sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01-mobile/encoder-epoch-12-avg-2-chunk-16-left-64.onnx') input_name = session.get_inputs()[0].name input_dict = {input_name: input_data} output_name = session.get_outputs()[0].name output = session.run([output_name], input_dict) 运行之后提示上面的报错信息,请问怎么解决呢

csukuangfj commented 1 week ago

使用模型的方式错误。

csukuangfj commented 1 week ago

建议先弄清楚模型的输入和输出,分别是什么,不要没弄清楚,就去写代码

2217895330 commented 1 week ago

请问哪里能了解这些吗,有推荐的吗大佬

csukuangfj commented 1 week ago

请去看icefall,有手把手教你的测试代码

csukuangfj commented 1 week ago

如果你能力够,直接看我们的c++代码,也是可以的

2217895330 commented 1 week ago

我看新一代kaldi的python-api有用zipformer进行kws检测,我想试着用c++推理还原里面的onnx推理

2217895330 commented 1 week ago

里面的c++代码我阅读起来太难了

2217895330 commented 1 week ago

所以想写一个麦克风采集加kws模型这样的代码

csukuangfj commented 1 week ago

重复一次,icefall 里面的zipformer 模型文件夹,有手把手教你的 onnx 模型 python 推理例子。