xinntao / ESRGAN

ECCV18 Workshops - Enhanced SRGAN. Champion PIRM Challenge on Perceptual Super-Resolution. The training codes are in BasicSR.
https://github.com/xinntao/BasicSR
Apache License 2.0
5.91k stars 1.05k forks source link

_pickle.UnpicklingError: invalid load key, '\x0a'. #67

Closed GrahamboJangles closed 5 years ago

GrahamboJangles commented 5 years ago
Traceback (most recent call last):
  File "test.py", line 15, in <module>
    model.load_state_dict(torch.load(model_path), strict=True)
  File "/usr/local/lib/python3.6/dist-packages/torch/serialization.py", line 387, in load
    return _load(f, map_location, pickle_module, **pickle_load_args)
  File "/usr/local/lib/python3.6/dist-packages/torch/serialization.py", line 564, in _load
    magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, '\x0a'.

I get this error when I try to run test.py

GrahamboJangles commented 5 years ago

Wow this one took me a while to figure out. I am using Google Colab, and the problem was that I was downloading using this piece of code:

import requests

url = 'https://doc-0g-7s-docs.googleusercontent.com/docs/securesc/gu7fim8g9hc82lbe7jugdq9q8rfet873/417jcvkoh8pc7ibbviv7fh56ikrt6c7k/1563912000000/15659024415184981874/11595594188083368607/1TPrz5QKd8DHHt1k8SRtm6tMiPjz_Qene?e=download&nonce=bsb79qdcnuhl8&user=11595594188083368607&hash=shn0lu5tium0m2ihso4lhluj24m8f5jf'

myfile = requests.get(url)

open('/content/ESRGAN/models/RRDB_ESRGAN_x4.pth', 'wb').write(myfile.content)

and I guess it didn't download right. So I manually downloaded the file locally then uploaded it and it works.