rrmina / fast-neural-style-pytorch

Fast Neural Style Transfer implementation in PyTorch :art: :art: :art:
315 stars 77 forks source link

vgg16_features.load_state_dict(torch.load(vgg_path), strict=False) #10

Closed mrlogick closed 4 years ago

mrlogick commented 4 years ago

I have no issues with stylize.py (with pretrained models). My problem is with train.py. I think I followed the instructions: downloaded vgg16-00b39a1b.pth, downloaded train2014, installed pytorch, opencv, etc (installed with conda). I have Debian 11 stable, Python 3.7.4, pytorch 1.4.0, torchvision 0.5.0, cudatoolkit 10.1.243.

$ python train.py

Traceback (most recent call last):
  File "train.py", line 168, in <module>
    train()
  File "train.py", line 50, in train
    VGG = vgg.VGG16().to(device)
  File "/home/mrfabiolo/style_transfer/fast-neural-style-pytorch/vgg.py", line 33, in __init__
    vgg16_features.load_state_dict(torch.load(vgg_path), strict=False)
  File "/home/mrfabiolo/miniconda3/lib/python3.7/site-packages/torch/serialization.py", line 529, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/home/mrfabiolo/miniconda3/lib/python3.7/site-packages/torch/serialization.py", line 692, in _legacy_load
    magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, '<'.

Same problem with device = "cpu" or device = "cuda". I got a GeForce GTX 750 card.

rrmina commented 4 years ago

Have you tried redownloading the vgg weights?

On Mon, Feb 3, 2020, 10:02 PM Fabio Vianello notifications@github.com wrote:

I have no issues with stylize.py (with pretrained models). My problem is with train.py. I think I followed the instructions: downloaded vgg16-00b39a1b.pth, downloaded train2014, installed pytorch, opencv, etc (installed with conda). I have Debian 11 stable, Python 3.7.4, pytorch 1.4.0, torchvision 0.5.0, cudatoolkit 10.1.243.

$ python train.py

Traceback (most recent call last): File "train.py", line 168, in train() File "train.py", line 50, in train VGG = vgg.VGG16().to(device) File "/home/mrfabiolo/style_transfer/fast-neural-style-pytorch/vgg.py", line 33, in init vgg16_features.load_state_dict(torch.load(vgg_path), strict=False) File "/home/mrfabiolo/miniconda3/lib/python3.7/site-packages/torch/serialization.py", line 529, in load return _legacy_load(opened_file, map_location, pickle_module, pickle_load_args) File "/home/mrfabiolo/miniconda3/lib/python3.7/site-packages/torch/serialization.py", line 692, in _legacy_load magic_number = pickle_module.load(f, pickle_load_args) _pickle.UnpicklingError: invalid load key, '<'.

Same problem with device = "cpu" or device = "cuda". I got a GeForce GTX 750 card.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rrmina/fast-neural-style-pytorch/issues/10?email_source=notifications&email_token=AB3NRXJOWZTPFVKQQICZ3NDRBAIX3A5CNFSM4KPEZMEKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IKSXDVA, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB3NRXJACJFRHWE3VK47GW3RBAIX3ANCNFSM4KPEZMEA .

mrlogick commented 4 years ago

Oh, i'm stupid. I simply clicked "save as" on the .pth link. But if I open it on the browser I get:

<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>E8CF943BCC893DFE</RequestId><HostId>8L/NToTygqd2LiDk2yhuGpgWphBTLhE0BCEvpc+AgBbroAQSvCVSO9Gm9hcbNh3pXftyg1HmJ78=</HostId></Error>

Do I need to sign up to amazonaws.com or something? Is it free?

rrmina commented 4 years ago

Seems like Justin Johnson has already stopped hosting the vgg weights. I've uploaded it in my Google Drive. Here's the link: https://drive.google.com/file/d/1a0sFcNEvmIy21PE0yp7tzJuU0vhhV0Ln/view?usp=sharing

Let me know if it works or not.

mrlogick commented 4 years ago

Yes! It works, thanks man