asteroid-team / asteroid

The PyTorch-based audio source separation toolkit for researchers
https://asteroid-team.github.io/
MIT License
2.21k stars 419 forks source link

'ConvTasNet' object has no attribute 'denoise' #269

Closed elenzheng closed 3 years ago

elenzheng commented 3 years ago

I am studying the recipe of /asteroid-master/egs/dns_challenge/. I modified the code at /asteroid-master/egs/dns_challenge/baseline/denoise.py as following to use the pretrained model for denoise:


from asteroid.models import ConvTasNet ... def main(conf):

Get best trained model

#model = load_best_model(conf["train_conf"], conf["exp_dir"])
model = ConvTasNet.from_pretrained('mpariente/ConvTasNet_WHAM!_sepclean')

Then when I run the denoise.py, it has error: 'ConvTasNet' object has no attribute 'denoise' Please find below error log message:


(base) root@elen-VirtualBox:/home/elen/lstm_rnn/asteroid-master/egs/dns_challenge/baseline# ./run.sh --tag iscomplex1_d97212aa Results from the following experiment will be stored in exp/train_dns_iscomplex1_d97212aa Stage 5 : Separate /home/elen/lstm_rnn/asteroid-master/asteroid/masknn/blocks.py:4: VisibleDeprecationWarning: blocks has been splited between convolutional and recurrent since asteroid v0.2.0 and will be removed in v0.3.0 warnings.warn( Using cached model mpariente/ConvTasNet_WHAM!_sepclean 0%| | 0/4 [00:00<?, ?it/s] Traceback (most recent call last): File "denoise.py", line 67, in main(arg_dic) File "denoise.py", line 51, in main estimate = model.denoise(net_inp).squeeze().cpu().data.numpy() File "/home/elen/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 771, in getattr raise ModuleAttributeError("'{}' object has no attribute '{}'".format( torch.nn.modules.module.ModuleAttributeError: 'ConvTasNet' object has no attribute 'denoise' (base) root@elen-VirtualBox:/home/elen/lstm_rnn/asteroid-master/egs/dns_challenge/baseline#


Can you please help me to point out if I missed anything? How can I use the pretrained model to do the denoise?

Thanks, Elen

mpariente commented 3 years ago

The model that is used for training is in the recipes' model.py and the eval script corresponds to this model.

We have one denoising model, which was trained on Librimix, you can use that one. But you cannot use a separation model for enhancement. If you want to use this model, you should probably replace the denoise with the separate.

elenzheng commented 3 years ago

Hi Mpariente,

Very glad to get your response so quickly. Can you point me out which model trained on Librimix can be used for denoising(enhancement)? Can you show me a brief example code how to use this denoising model for enhancement?

Thanks, Elen

mpariente commented 3 years ago

The file with enh in it, for enhancement. Go to the model hub. And for an example, see the docs. If something is not clear in the docs, please give feedback. I cannot give personalized feedback to all users, that won't scale.

mpariente commented 3 years ago

And when you find your solution, please describe it in this issue to help future users, thanks.

elenzheng commented 3 years ago

Now I understand why that pretrained model cannot use denoise() method. Because every pretrained model is trained by a specific recipe, if the model in that recipe did not have denoise() method, then I cannot use it. Unfortunately, I cannot find any pretrained model in the model hub was trained using the asteroid/dns_challenge recipe. So in the code /asteroid-master/egs/dns_challenge/baseline/denoise.py I have no way to directly use any pretrained model to do speech enhancement(denoising).

mpariente commented 3 years ago

Correct. The DNS challenge recipe is really just an example of how to use asteroid, it's not made for performance.

mpariente commented 3 years ago

Closing this.