Paper99 / SRFBN_CVPR19

Pytorch code for our paper "Feedback Network for Image Super-Resolution" (CVPR2019)
MIT License
551 stars 126 forks source link

issue about code on cpu ,no GPUs #36

Closed cvJie closed 5 years ago

cvJie commented 5 years ago

I want to quick run the test.py ,download pre-trained model and mv to models, add SRSolver.py 305:checkpoint = torch.load(model_path,map_location='cpu'), but errors :

File "/*/srfbn/solvers/SRSolver.py", line 308, in load else self.model.module.load_state_dict

AttributeError: 'SRFBN' object has no attribute 'module'

please give me some advices, thanks

codeman008 commented 5 years ago

I have the same problem. Have you solved it?

Whu-wxy commented 4 years ago

I ran through in cpu mode, modified as follows:

  1. In SRSolver.py 305:
    
    checkpoint = torch.load(model_path, torch.device('cpu')) 
    if 'state_dict' in checkpoint.keys(): checkpoint = checkpoint['state_dict'] 

temp_dict = {} model_dict = self.model.state_dict() for i, key in enumerate(checkpoint.keys()): if key.startswith('module'): key2 = key[7:] else: key2 = key temp_dict[key2] = checkpoint[key] model_dict.update(temp_dict) self.model.load_state_dict(model_dict)



2. In XXX_arch.py:
change cuda() to cpu()