sanghyun-son / EDSR-PyTorch

PyTorch version of the paper 'Enhanced Deep Residual Networks for Single Image Super-Resolution' (CVPRW 2017)
MIT License
2.41k stars 666 forks source link

It is not working Correctly! #349

Open MuhammadShahzeb123 opened 1 year ago

MuhammadShahzeb123 commented 1 year ago

Brothers, I have tested the Model on Windows using Python ( Because of the dome.sh could not run ). In this code:

import torch
from torch.autograd import Variable
from PIL import Image
from torchvision.transforms import ToTensor, ToPILImage

from src import option
from src.model import edsr

model_path = "experiment/edsr_baseline_x2-1bc95232.pt"
args = option.args
args.n_resblocks = 16
args.n_feats = 64
args.rgb_range = 255
args.res_scale = 1
args.n_colors = 3
args.scale = [2]

model = edsr.EDSR(args=args)
model.load_state_dict(torch.load(model_path, map_location=lambda storage, loc: storage))
model.eval()

input_image_path = "Aneesa.jpg"
image = Image.open(input_image_path).convert('RGB')
image = ToTensor()(image).unsqueeze(0)

with torch.no_grad():
    input_image = Variable(image)
    upscaled_image = model(input_image)

output_image_path = "image.jpg"
upscaled_image = ToPILImage()(upscaled_image.squeeze(0))
upscaled_image.save(output_image_path)

It turned the picture: Aneesa

Into this Picture: image

Can anyone help me with that because I am a true beginner and I want to adopt this field