EOFError: Ran out of input when I load pretrained vggface2 via InceptionResnetV1

Hi @ptrblck ,
I am trying to load pretrained vggface2 model via the following command:

 from facenet_pytorch import  InceptionResnetV1
 resnet = InceptionResnetV1(pretrained='vggface2').eval()

and I get the following error:

EOFError                                  Traceback (most recent call last)
<ipython-input-4-bec9f4ede2ac> in <module>
----> 1 resnet = InceptionResnetV1(pretrained='vggface2').eval()

c:\users\iarya\anaconda3\envs\opencv-env\lib\site-packages\facenet_pytorch\models\inception_resnet_v1.py in __init__(self, pretrained, classify, num_classes, dropout_prob, device)
    260         if pretrained is not None:
--> 261             load_weights(self, pretrained)
    263         if self.num_classes is not None:

c:\users\iarya\anaconda3\envs\opencv-env\lib\site-packages\facenet_pytorch\models\inception_resnet_v1.py in load_weights(mdl, name)
    334             with open(cached_file, 'wb') as f:
    335                 f.write(r.content)
--> 336         state_dict.update(torch.load(cached_file))
    338     mdl.load_state_dict(state_dict)

c:\users\iarya\anaconda3\envs\opencv-env\lib\site-packages\torch\serialization.py in load(f, map_location, pickle_module, **pickle_load_args)
    591                     return torch.jit.load(f)
    592                 return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
--> 593         return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)

c:\users\iarya\anaconda3\envs\opencv-env\lib\site-packages\torch\serialization.py in _legacy_load(f, map_location, pickle_module, **pickle_load_args)
    761             "functionality.".format(type(f)))
--> 763     magic_number = pickle_module.load(f, **pickle_load_args)
    764     if magic_number != MAGIC_NUMBER:
    765         raise RuntimeError("Invalid magic number; corrupt file?")

EOFError: Ran out of input

Can anyone provide the solution please?


This error is raised by pickle, if the file is empty or is parts are missing.
Could you check the file size?

Hey @ptrblck,

The files are present at these links:



They both are downloadable and non empty when downloaded separately

I am following the exact steps as mentioned on :

Could you manage to fix the issue? I am running into the same problem.