Loading pretrained model error

Hi,

I was downaloding vgg19 pretrained model, but it stopped because of not enough space.

So, after making enough space I tried redownloading the model with

torchvision.models.vgg19(pretrained=True)

but I got error saying


RuntimeError Traceback (most recent call last)
in ()
----> 1 vgg = torchvision.models.vgg19(pretrained=True)

~/anaconda3/lib/python3.6/site-packages/torchvision-0.1.9-py3.6.egg/torchvision/models/vgg.py in vgg19(pretrained, > > **kwargs)
164 model = VGG(make_layers(cfg[‘E’]), **kwargs)
165 if pretrained:
→ 166 model.load_state_dict(model_zoo.load_url(model_urls[‘vgg19’]))
167 return model
168

~/anaconda3/lib/python3.6/site-packages/torch/utils/model_zoo.py in load_url(url, model_dir, map_location)
56 hash_prefix = HASH_REGEX.search(filename).group(1)
57 _download_url_to_file(url, cached_file, hash_prefix)
—> 58 return torch.load(cached_file, map_location=map_location)
59
60

~/anaconda3/lib/python3.6/site-packages/torch/serialization.py in load(f, map_location, pickle_module)
229 f = open(f, ‘rb’)
230 try:
→ 231 return _load(f, map_location, pickle_module)
232 finally:
233 if new_fd:

~/anaconda3/lib/python3.6/site-packages/torch/serialization.py in _load(f, map_location, pickle_module)
384 for key in deserialized_storage_keys:
385 assert key in deserialized_objects
→ 386 deserialized_objects[key]._set_from_file(f, offset)
387 offset = None
388

RuntimeError: unexpected EOF. The file might be corrupted.

How can I solve it?

Try to clear the downloaded model and download it again? On my CentOS, the model is stored in ~/.torch/models directory.

Oh thanks a lot!!

I thought it is ~/torch/models not ~/.torch/models so I couldn’t find downloaded file.

If it solves your problem, you can mark my answer as solution.

1 Like

If you are using Window 10 machine, deleting vgg16-something in folder C:\Users\UserName\.cache\torch\checkpoints would solve probelm.