hamzakashif's picture
Update app.py
cafa4a8 verified
raw
history blame contribute delete
547 Bytes
import torch
from PIL import Image
import numpy as np
from RealESRGAN import RealESRGAN
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model = RealESRGAN(device, scale=4)
model.load_weights('weights/RealESRGAN_x4.pth', download=False)
model.load_weights('weights/RealESRGAN_x4.pth', download=False)
model.load_weights('weights/RealESRGAN_x4.pth', download=False)
path_to_image = 'inputs/lr_image.png'
image = Image.open(path_to_image).convert('RGB')
sr_image = model.predict(image)
sr_image.save('results/sr_image.png')