dvector
dvector copied to clipboard
model loading issue
I am using pre-trained model to get the embedding but getting below error:
RuntimeError Traceback (most recent call last)
<ipython-input-5-4bcf886e7e7f> in <module>
2 import torchaudio
3
----> 4 wav2mel = torch.jit.load("wav2mel.pt")
5 dvector = torch.jit.load("dvector.pt").eval()
6
~/anaconda3/lib/python3.8/site-packages/torch/jit/_serialization.py in load(f, map_location, _extra_files)
159 cu = torch._C.CompilationUnit()
160 if isinstance(f, str) or isinstance(f, pathlib.Path):
--> 161 cpp_module = torch._C.import_ir_module(cu, str(f), map_location, _extra_files)
162 else:
163 cpp_module = torch._C.import_ir_module_from_buffer(
RuntimeError:
Class Namespace cannot be used as a value:
Serialized File "code/__torch__/torchaudio/sox_effects/sox_effects.py", line 5
effects: List[List[str]],
channels_first: bool=True) -> Tuple[Tensor, int]:
in_signal = __torch__.torch.classes.torchaudio.TensorSignal.__new__(__torch__.torch.classes.torchaudio.TensorSignal)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
_0 = (in_signal).__init__(tensor, sample_rate, channels_first, )
out_signal = ops.torchaudio.sox_effects_apply_effects_tensor(in_signal, effects)
'apply_effects_tensor' is being compiled since it was called from 'SoxEffects.forward'
Serialized File "code/__torch__/data/wav2mel.py", line 29
wav_tensor: Tensor,
sample_rate: int) -> Tensor:
_0 = __torch__.torchaudio.sox_effects.sox_effects.apply_effects_tensor
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
_1 = _0(wav_tensor, sample_rate, self.effects, True, )
wav_tensor1, _2, = _1
I myself also encountered this after upgrading torch to 1.8.0 and torchaudio to 0.8.0. I will try my best to fix this ASAP!
Looking forward for this to be fixed, since I find myself in the same situation. Thanks for your great work, by the way!
I just realized that the default backend has been changed from sox to sox_io in torchaudio 0.8.0. I'm not very sure whether this causes the problem, but ever since I recompiled the Wav2Mel module, it works just fine. Plan to upload the new module tomorrow.
The newly compiled modules have been uploaded with the new release.
Great, thank you! Eager to try them!
Still didn't work for me:
Message= Unknown builtin op: torchaudio::sox_effects_apply_effects_tensor. Could not find any similar ops to torchaudio::sox_effects_apply_effects_tensor. This op may not exist or may not be currently supported in TorchScript. : File "/home/yist/.pyenv/versions/3.8.5/lib/python3.8/site-packages/torchaudio/sox_effects/sox_effects.py", line 151 >>> assert sample_rate == 8000 """ return torch.ops.torchaudio.sox_effects_apply_effects_tensor( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE tensor, sample_rate, effects, channels_first) Serialized File "code/torch/torchaudio/sox_effects/sox_effects.py", line 5 effects: List[List[str]], channels_first: bool=True) -> Tuple[Tensor, int]: _0, _1 = ops.torchaudio.sox_effects_apply_effects_tensor(tensor, sample_rate, effects, channels_first) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE return (_0, _1) 'apply_effects_tensor' is being compiled since it was called from 'SoxEffects.forward' Serialized File "code/torch/data/wav2mel.py", line 31 wav_tensor: Tensor, sample_rate: int) -> Tensor: _0 = torch.torchaudio.sox_effects.sox_effects.apply_effects_tensor ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE _1 = _0(wav_tensor, sample_rate, self.effects, True, ) wav_tensor1, _2, = _1
Source=***
StackTrace:
File "***", line 11, in
Did you import torchaudio before loading the wav2mel.pt module?
Yes, my code is as in the example:
import torch # This is 1.8.0 import torchaudio # This is 0.8.0
wav2mel = torch.jit.load(r"yistLin dvector\wav2mel.pt") # Error
Exactly those (sorry, updated the comment a bit too late)
@ADD-eNavarro Can you try to compile the modules? You can simply run the preprocessing script and those modules will be generated and saved with the preprocessed data. Or you can do it manually like this:
# in the root directory of the repo
import torch
import torchaudio
from data.wav2mel import Wav2Mel
wav2mel = Wav2Mel()
wav2mel = torch.jit.script(wav2mel)
wav2mel.save("wav2mel.pt")
I get an error in: wav2mel = torch.jit.script(wav2mel)
Message= undefined value torch: File "\AppData\Roaming\Python\Python37\site-packages\torchaudio_internal\module_utils.py", line 151 >>> assert sample_rate == 8000 """ return torch.ops.torchaudio.sox_effects_apply_effects_tensor( ~~~~~ <--- HERE tensor, sample_rate, effects, channels_first) 'apply_effects_tensor' is being compiled since it was called from 'SoxEffects.forward' File "\yistLin_dVector\data\wav2mel.py", line 72 def forward(self, wav_tensor: torch.Tensor, sample_rate: int) -> torch.Tensor: wav_tensor, _ = apply_effects_tensor(wav_tensor, sample_rate, self.effects) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE return wav_tensor
Source=\yistLin_dVector\Test.py
StackTrace:
File "\yistLin_dVector\Test.py", line 7, in
Got it, now I see some problems:
- Do you have
soxinstalled on your machine? - From those logs you posted, I guess you're using Windows. But I'm not 100% sure whether torchaudio's SoxEffects works on Windows as on Linux/Mac OS.
Reading torchaudio's docs, it says that the sox_io backend works on Linux/Mac OS only, but I didn't see any warnings like: SoxEffects does not work on Windows...
You're right, I'm working on Windows. Sox is installed, sox_io won't install on Windows. That might be the cause indeed. I will look into it too, but it would be a pity to discard Windows users like that...
@ADD-eNavarro Can you try to compile the modules? You can simply run the preprocessing script and those modules will be generated and saved with the preprocessed data. Or you can do it manually like this:
# in the root directory of the repo import torch import torchaudio from data.wav2mel import Wav2Mel wav2mel = Wav2Mel() wav2mel = torch.jit.script(wav2mel) wav2mel.save("wav2mel.pt")
hi, i follow your solution in linux,but still not solve?
by the way, can you share you source model? TorchScript should be consistent with your version
@liyuanyaun Can you show me the error messages or describe more about which step went wrong?
I just tested the TorchScript modules on Google Colab, and nothing went wrong. Here's the link: https://colab.research.google.com/drive/1yNMPOCxyUYVr03pYm6kix8Vm0ICThGAe?usp=sharing
@liyuanyaun Can you show me the error messages or describe more about which step went wrong?
I just tested the TorchScript modules on Google Colab, and nothing went wrong. Here's the link: https://colab.research.google.com/drive/1yNMPOCxyUYVr03pYm6kix8Vm0ICThGAe?usp=sharing
my error is same as ADD-eNavarro Unknown builtin op: torchaudio::sox_effects_apply_effects_tensor. Could not find any similar ops to torchaudio::sox_effects_apply_effects_tensor. This op may not exist or may not be currently supported in TorchScript.
and i follow your sulution:
in the root directory of the repo
import torch import torchaudio
from data.wav2mel import Wav2Mel
wav2mel = Wav2Mel() wav2mel = torch.jit.script(wav2mel) wav2mel.save("wav2mel.pt")
but it did not work
@liyuanyaun Can you show me the error messages or describe more about which step went wrong?
I just tested the TorchScript modules on Google Colab, and nothing went wrong. Here's the link: https://colab.research.google.com/drive/1yNMPOCxyUYVr03pYm6kix8Vm0ICThGAe?usp=sharing
my error is same as ADD-eNavarro Unknown builtin op: torchaudio::sox_effects_apply_effects_tensor. Could not find any similar ops to torchaudio::sox_effects_apply_effects_tensor. This op may not exist or may not be currently supported in TorchScript.
and i follow your sulution:
in the root directory of the repo
import torch import torchaudio
from data.wav2mel import Wav2Mel
wav2mel = Wav2Mel() wav2mel = torch.jit.script(wav2mel) wav2mel.save("wav2mel.pt")
but it did not work
It works on Linux well. The reported problem appears just in Windows :\
Hello does this solved? I have the same problem in windows.