File size: 439 Bytes
9b879f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import torch
from PIL import Image
import numpy as np
from .esrgan.RealESRGAN import RealESRGAN
def sr(img):
   # device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
    device=torch.device("cuda")
    model = RealESRGAN(device, scale=2)
    model.load_weights('weights/RealESRGAN_x2.pth', download=True)


    img=Image.fromarray(img)
    sr_image = model.predict(img)
    sr_image=np.array(sr_image)
    return sr_image