melgan icon indicating copy to clipboard operation
melgan copied to clipboard

Torch hub command not working

Open raphpapercup opened this issue 4 years ago • 10 comments

Hello, Thanks a lot for your implementation. I am slightly confused because I am trying to run your torch hub command but it does not work. image

Also if I look in /home/user/.cache/torch/checkpoints/, I cannot find the checkpoint even though I do get the logging: Downloading: "https://github.com/seungwonpark/melgan/releases/download/v0.1-alpha/nvidia_tacotron2_LJ11_epoch3200.pt" to /home/user/.cache/torch/checkpoints/nvidia_tacotron2_LJ11_epoch3200.pt

raphpapercup avatar Oct 29 '19 15:10 raphpapercup

Hi, can you please briefly describe about your environment?

In my case, it worked for CentOS but not for Windows 10.

seungwonpark avatar Oct 29 '19 15:10 seungwonpark

Not OP but exactly the same error here. Environment:

  • Ubuntu 16.04.06 LTS 'xenial'
  • Python 3.6.9 (Anaconda)
  • Pytorch 1.1.0
  • CUDA 9.0_0, CuDNN 7.6.0

HTH - would be nice to try your work!

te0006 avatar Oct 29 '19 18:10 te0006

@raphpapercup @te0006 Have you solve this error? I encountered the same error.

MorganCZY avatar Nov 11 '19 08:11 MorganCZY

Bug is still persisting.

phtephanx avatar Dec 09 '19 10:12 phtephanx

I tried a different approach of manually downloading the pretrained model and then try loading it via PyTorch, and I hit a different bug for that. image

delip avatar Jan 04 '20 01:01 delip

This worked for me. I downloaded the checkpoint from the releases page.

from melgan.model.generator import Generator
from melgan.utils.hparams import HParam

checkpoint = torch.load("./nvidia_tacotron2_LJ11_epoch6400.pt") 
hp = HParam("./melgan/config/default.yaml")

melgan = Generator(hp.audio.n_mel_channels).cuda()
melgan.load_state_dict(checkpoint["model_g"])
melgan.eval(inference=False)

jacobhallberg avatar Jan 22 '20 21:01 jacobhallberg

I am having the same issue. not able to download the pretrained checkpoint.

hash_prefix = HASH_REGEX.search(filename).group(1) AttributeError: 'NoneType' object has no attribute 'group'

This worked for me. I downloaded the checkpoint from the releases page.

from melgan.model.generator import Generator
from melgan.utils.hparams import HParam

checkpoint = torch.load("./nvidia_tacotron2_LJ11_epoch6400.pt") 
hp = HParam("./melgan/config/default.yaml")

melgan = Generator(hp.audio.n_mel_channels).cuda()
melgan.load_state_dict(checkpoint["model_g"])
melgan.eval(inference=False)

This also worked for me. Go to Releases and download the checkpoint from the last release.

janvainer avatar Mar 06 '20 08:03 janvainer

I tried a different approach of manually downloading the pretrained model and then try loading it via PyTorch, and I hit a different bug for that. image

@delip you should reach checkpoint's generator module by loading the state dict via:

model.load_state_dict(torch.load('nvidia-tacotron2_LJ11_epoch6400.pt')['model_g'])

instead of

model.load_state_dict(torch.load('nvidia-tacotron2_LJ11_epoch6400.pt'))

deepconsc avatar May 16 '20 20:05 deepconsc

having the same issue with torch.hub.load_state_dict_from_url()

yihan0512 avatar Sep 07 '20 23:09 yihan0512

I had the same problem but, in another application. In my case, I am the model "provider". Computing the SHA-256 Hash of the file and adding it to the checkpoint filename worked for me.

  1. On Linux, I ran: sha256sum <checkpoint_model_filename.ext>
  2. I copied the first eight digits of the hash and added them to the filename: checkpoint_model_filename-<sha256>.ext
  3. Then, I changed the filename in the release.

So, in this case, the model's filename should be https://github.com/seungwonpark/melgan/releases/download/v0.1-alpha/nvidia_tacotron2_LJ11_epoch3200-<sha256>.pt

Source: https://pytorch.org/docs/stable/hub.html#torch.hub.load_state_dict_from_url

washingtonsk8 avatar Feb 07 '21 14:02 washingtonsk8