Lornatang / SRGAN-PyTorch

A simple and complete implementation of super-resolution paper.
Apache License 2.0
410 stars 105 forks source link

Validation Error in loading state_dict for Generator #52

Closed hurkal closed 2 years ago

hurkal commented 2 years ago

Hi. I got this error message while validating on Colab:

RuntimeError: Error(s) in loading state_dict for Generator:
    Missing key(s) in state_dict: "conv_block1.0.weight", "conv_block1.0.bias", "conv_block1.1.weight", "trunk.0.rcb.0.weight", "trunk.0.rcb.1.weight", "trunk.0.rcb.1.bias", 
     ... 
     "upsampling.1.upsample_block.0.bias", "upsampling.1.upsample_block.2.weight", "conv_block3.weight", "conv_block3.bias". 
    Unexpected key(s) in state_dict: "epoch", "best_psnr", "state_dict", "optimizer", "scheduler". 

Tries to use this weight file: SRGAN_x4-ImageNet-2204c839.pth.tar as provided in the link

To overcome the error, updated the code; model.load_state_dict(checkpoint["state_dict"]) to model.load_state_dict(checkpoint["state_dict"],False) in validate.py on line 34.

After changing, validation works but PSNR is only 8.89dB. I tried also all weight files of SRGAN in the link but all 3 of them have the same PSNR result: 8.89

baby

Which point have I missed?

Lornatang commented 2 years ago

I'm very sorry, this should be my weight upload error, please click the link again to download the latest weight.

hurkal commented 2 years ago

Thank you very much for this project and quick answer.