风格迁移 RuntimeError: storage has wrong size: expected 16825408 got 256

闲着试一下风格迁移,pytorch0.4,python3,windows系统

尝试使用了:

http://www.pytorchtutorial.com/pytorch-style-transfer/

https://blog.csdn.net/zzlyw/article/details/78849250

提供的代码,在此先感谢两篇文章的作者

但是都遇到了



...(之前省略)

  File "F:\ANACONDA\envs\pytorch\lib\site-packages\torchvision\models\vgg.py", line 181, in vgg19
    model.load_state_dict(model_zoo.load_url(model_urls['vgg19']))

  File "F:\ANACONDA\envs\pytorch\lib\site-packages\torch\utils\model_zoo.py", line 66, in load_url
    return torch.load(cached_file, map_location=map_location)

  File "F:\ANACONDA\envs\pytorch\lib\site-packages\torch\serialization.py", line 303, in load
    return _load(f, map_location, pickle_module)

  File "F:\ANACONDA\envs\pytorch\lib\site-packages\torch\serialization.py", line 476, in _load
    deserialized_objects[key]._set_from_file(f, offset, f_is_real_file)

RuntimeError: storage has wrong size: expected 16825408 got 256

的问题,百度无果,然后猜测可能是模型加载的问题,因此将vgg.py模型加载从

风格迁移 RuntimeError: storage has wrong size: expected 16825408 got 256_第1张图片

红框中注释掉的是源代码的,黑色是我经过下载vgg19模型,然后放到同级文件夹后直接加载模型参数的代码

修改之后模型得以正常运行。

你可能感兴趣的:(深度学习)