PytorchInsight icon indicating copy to clipboard operation
PytorchInsight copied to clipboard

Unable to load sk_resnet50.pth

Open ghost opened this issue 6 years ago • 3 comments

Hi, I got the following error when try to load sk_resnet50.pth

>>> checkpoint1 = torch.load('sk_resnet50.pth.tar', map_location=torch.device('cpu'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jinchen/.local/lib/python3.6/site-packages/torch/serialization.py", line 426, in load
    return _load(f, map_location, pickle_module, **pickle_load_args)
  File "/home/jinchen/.local/lib/python3.6/site-packages/torch/serialization.py", line 620, in _load
    deserialized_objects[key]._set_from_file(f, offset, f_should_read_directly)
RuntimeError: unexpected EOF, expected 3594295 more bytes. The file might be corrupted.

is t because map_location uses CPU? but others seem fine, only this model has the error Thanks!

ghost avatar Dec 30 '19 13:12 ghost

Hey there, got exactly the same issue and I'm using CUDA as a device.

SK_resnet101 works perfectly though

timothyMbehold avatar Jun 05 '20 18:06 timothyMbehold

Hey there, got exactly the same issue and I'm using CUDA as a device.

SK_resnet101 works perfectly though

my code:

     def get_se_resnet101(path_state_dict, device, vis_model=False):

             model = resnet_se.se_resnet101() 

            if path_state_dict:

                 pretrained_state_dict = torch.load(path_state_dict, map_location=torch.device('cpu')) 

                 model.load_state_dict(pretrained_state_dict, )

`

error:

raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for ResNet:

  Missing key(s) in state_dict: "conv1.weight", "bn1.weight", "bn1.bias", "bn1.running_mean", "bn1.running_var", ......

  Unexpected key(s) in state_dict: "epoch", "state_dict", "acc", "best_acc", "optimizer"

How to solve it? thanks

creater-zq avatar Feb 15 '21 16:02 creater-zq

Hi, I got the following error when try to load sk_resnet50.pth

>>> checkpoint1 = torch.load('sk_resnet50.pth.tar', map_location=torch.device('cpu'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jinchen/.local/lib/python3.6/site-packages/torch/serialization.py", line 426, in load
    return _load(f, map_location, pickle_module, **pickle_load_args)
  File "/home/jinchen/.local/lib/python3.6/site-packages/torch/serialization.py", line 620, in _load
    deserialized_objects[key]._set_from_file(f, offset, f_should_read_directly)
RuntimeError: unexpected EOF, expected 3594295 more bytes. The file might be corrupted.

is t because map_location uses CPU? but others seem fine, only this model has the error Thanks!

my code:

     def get_se_resnet101(path_state_dict, device, vis_model=False):

             model = resnet_se.se_resnet101() 

            if path_state_dict:

                 pretrained_state_dict = torch.load(path_state_dict, map_location=torch.device('cpu')) 

                 model.load_state_dict(pretrained_state_dict, )

`

error:

raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for ResNet:

  Missing key(s) in state_dict: "conv1.weight", "bn1.weight", "bn1.bias", "bn1.running_mean", "bn1.running_var", ......

How to address this issue? thanks

creater-zq avatar Feb 15 '21 16:02 creater-zq