[GH-ISSUE #415] onnx_inference_demo how do I get the vec-256-layer-9? #212

Closed
opened 2026-10-20 09:56:45 +00:00 by bsakaguchi · 7 comments
Owner

Originally created by @mathigatti on GitHub (Jun 2, 2023).
Original GitHub issue: https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI/issues/415

Hi! I'm trying to test the onnx_inference_demo.py script, I created a model.onnx using the export_onnx.py script and set that as model_path. But now it looks like I'm missing that "vec_name" thing, not sure how should I generate that file.

These are lines I'm talking about at onnx_inference_demo.py

model_path = "model.onnx"  # 模型的完整路径
vec_name = "vec-256-layer-9"  # 内部自动补齐为 f"pretrained/{vec_name}.onnx" 需要onnx的vec模型
Originally created by @mathigatti on GitHub (Jun 2, 2023). Original GitHub issue: https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI/issues/415 Hi! I'm trying to test the [onnx_inference_demo.py](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI/blob/main/onnx_inference_demo.py) script, I created a model.onnx using the export_onnx.py script and set that as model_path. But now it looks like I'm missing that "vec_name" thing, not sure how should I generate that file. These are lines I'm talking about at onnx_inference_demo.py ```python model_path = "model.onnx" # 模型的完整路径 vec_name = "vec-256-layer-9" # 内部自动补齐为 f"pretrained/{vec_name}.onnx" 需要onnx的vec模型 ```
Author
Owner

@mathigatti commented on GitHub (Jun 2, 2023):

okay it looks like it's contentVec ported to onnx, I just found it here.

<!-- gh-comment-id:1574257549 --> @mathigatti commented on GitHub (Jun 2, 2023): okay it looks like it's contentVec ported to onnx, I just found it [here](https://huggingface.co/NaruseMioShirakana/MoeSS-SUBModel/tree/main).
Author
Owner

@SirHumphreyforreal commented on GitHub (Mar 1, 2024):

sorry to interrupt,I encounter the same thing as you did,I follow your link to download this"vec-256-layer-9" thing ,but it keeps telling me
"Load model from pretrained/vec-256-layer-9.onnx failed:Load model pretrained/vec-256-layer-9.onnx failed. File doesn't exist"
wherever I store it, even I use absolute path.
I really dont know what goes wrong,pls help me

<!-- gh-comment-id:1973530130 --> @SirHumphreyforreal commented on GitHub (Mar 1, 2024): sorry to interrupt,I encounter the same thing as you did,I follow your link to download this"vec-256-layer-9" thing ,but it keeps telling me "Load model from pretrained/vec-256-layer-9.onnx failed:Load model pretrained/vec-256-layer-9.onnx failed. File doesn't exist" wherever I store it, even I use absolute path. I really dont know what goes wrong,pls help me
Author
Owner

@mathigatti commented on GitHub (Mar 1, 2024):

share your code

<!-- gh-comment-id:1973553449 --> @mathigatti commented on GitHub (Mar 1, 2024): share your code
Author
Owner

@SirHumphreyforreal commented on GitHub (Mar 2, 2024):

Here is the code:

import soundfile
from ..infer.lib.infer_pack.onnx_inference import OnnxRVC

hop_size = 512
sampling_rate = 40000 # 采样率
f0_up_key = 0 # 升降调
sid = 0 # 角色ID
f0_method = "dio" # F0提取算法
model_path = "test.onnx" # 模型的完整路径
vec_name = (
"vec-256-layer-9.onnx" # 内部自动补齐为 f"pretrained/{vec_name}.onnx" 需要onnx的vec模型
)
wav_path = "sunflower.wav" # 输入路径或ByteIO实例
out_path = "out.wav" # 输出路径或ByteIO实例

model = OnnxRVC(
model_path, vec_path=vec_name, sr=sampling_rate, hop_size=hop_size, device="cuda"
)

audio = model.inference(wav_path, sid, f0_method=f0_method, f0_up_key=f0_up_key)

soundfile.write(out_path, audio, sampling_rate)

and output in terminal as follows:

Traceback (most recent call last):
File "D:\QT\test.py", line 17, in
model = OnnxRVC(
File "D:\QT\onnx.py", line 74, in init
self.vec_model = ContentVec(vec_path, device)
File "D:\QT\onnx.py", line 22, in init
self.model = onnxruntime.InferenceSession(vec_path, providers=providers)
File "C:\Python38\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 419, in init
self._create_inference_session(providers, provider_options, disabled_optimizers)
File "C:\Python38\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 472, in _create_inference_session
sess = C.InferenceSession(session_options, self._model_path, True, self._read_config_from_model)
onnxruntime.capi.onnxruntime_pybind11_state.NoSuchFile: [ONNXRuntimeError] : 3 : NO_SUCHFILE : Load model from pretrained/vec-256-layer-9.onnx failed:Load model pretrained/vec-256-layer-9.onnx failed. File doesn't exist

<!-- gh-comment-id:1974263561 --> @SirHumphreyforreal commented on GitHub (Mar 2, 2024): Here is the code: import soundfile from ..infer.lib.infer_pack.onnx_inference import OnnxRVC hop_size = 512 sampling_rate = 40000 # 采样率 f0_up_key = 0 # 升降调 sid = 0 # 角色ID f0_method = "dio" # F0提取算法 model_path = "test.onnx" # 模型的完整路径 vec_name = ( "vec-256-layer-9.onnx" # 内部自动补齐为 f"pretrained/{vec_name}.onnx" 需要onnx的vec模型 ) wav_path = "sunflower.wav" # 输入路径或ByteIO实例 out_path = "out.wav" # 输出路径或ByteIO实例 model = OnnxRVC( model_path, vec_path=vec_name, sr=sampling_rate, hop_size=hop_size, device="cuda" ) audio = model.inference(wav_path, sid, f0_method=f0_method, f0_up_key=f0_up_key) soundfile.write(out_path, audio, sampling_rate) and output in terminal as follows: Traceback (most recent call last): File "D:\QT\test.py", line 17, in <module> model = OnnxRVC( File "D:\QT\onnx.py", line 74, in __init__ self.vec_model = ContentVec(vec_path, device) File "D:\QT\onnx.py", line 22, in __init__ self.model = onnxruntime.InferenceSession(vec_path, providers=providers) File "C:\Python38\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 419, in __init__ self._create_inference_session(providers, provider_options, disabled_optimizers) File "C:\Python38\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 472, in _create_inference_session sess = C.InferenceSession(session_options, self._model_path, True, self._read_config_from_model) onnxruntime.capi.onnxruntime_pybind11_state.NoSuchFile: [ONNXRuntimeError] : 3 : NO_SUCHFILE : Load model from pretrained/vec-256-layer-9.onnx failed:Load model pretrained/vec-256-layer-9.onnx failed. File doesn't exist
Author
Owner

@mathigatti commented on GitHub (Mar 2, 2024):

How are you running it and where is the pretrained folder located? I think you should run it from the source folder (python tools/onnx_inference_demo.py) of the project and place the pretrained folder there in the root directory too

<!-- gh-comment-id:1974795169 --> @mathigatti commented on GitHub (Mar 2, 2024): How are you running it and where is the pretrained folder located? I think you should run it from the source folder (python tools/onnx_inference_demo.py) of the project and place the pretrained folder there in the root directory too
Author
Owner

@ZzAR0 commented on GitHub (Mar 3, 2024):

Hi, I have a similar problem, I have vec-256-layer-9.onnx under the same file as vec-768-layer-12.onnx.
But there was an error:onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Got invalid dimensions for input: phone for the following indices
index: 2 Got: 256 Expected: 768 Please fix either the inputs/outputs or the model.

<!-- gh-comment-id:1975080943 --> @ZzAR0 commented on GitHub (Mar 3, 2024): Hi, I have a similar problem, I have vec-256-layer-9.onnx under the same file as vec-768-layer-12.onnx. But there was an error:onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Got invalid dimensions for input: phone for the following indices index: 2 Got: 256 Expected: 768 Please fix either the inputs/outputs or the model.
Author
Owner

@ZzAR0 commented on GitHub (Mar 3, 2024):

Also ask why the onnx model for inference works so poorly and whether onnx can now use the rmvpe algorithm Thanks.

<!-- gh-comment-id:1975081376 --> @ZzAR0 commented on GitHub (Mar 3, 2024): Also ask why the onnx model for inference works so poorly and whether onnx can now use the rmvpe algorithm Thanks.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
RVC-Project/Retrieval-based-Voice-Conversion-WebUI#212
No description provided.