Lornatang / SRGAN-PyTorch

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

upscale_factor has no effect #56

Closed eformx closed 1 year ago

eformx commented 2 years ago

I changed upscale_factor = 2 in config.py I run inferernce.py and results are upscaled by 4. How can I pass in an upscale_factor of 2 in inference.py?

Lornatang commented 2 years ago

OK, you need to modify two places. 1- Change config.py 31 line upscale_factor = 4 to upscale_factor = 2 2- Change model.py 139 line for _ in range(2): to for _ in range(1):

Lornatang commented 2 years ago

So, inferernce.py should use X4 model weights, if you use X2 model weights, maybe it is bad~ I'm talking about the case of using the pretrained model directly ^.^

eformx commented 2 years ago

Tried your suggestion but get: RuntimeError: Error(s) in loading state_dict for Generator: Unexpected key(s) in state_dict: "upsampling.1.upsample_block.0.weight", "upsampling.1.upsample_block.0.bias", "upsampling.1.upsample_block.2.weight".

I am using: model_path = "/results/pretrained_models/SRResNet_x4-ImageNet-2096ee7f.pth.tar"

Lornatang commented 2 years ago

This library gives X4 times the model, which cannot be directly used for X2 inference, you can try to load some model weights

eformx commented 2 years ago

Will this work or is there a better one: Discriminator_x2-DFO2K-e37ff529.pth.tar