File size: 1,174 Bytes
49569aa
1bca832
1672592
c9a49d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
518cfb2
c9a49d0
a12e19d
 
 
c9a49d0
518cfb2
c9a49d0
 
 
518cfb2
c9a49d0
 
 
518cfb2
881f7d2
518cfb2
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
os.system("pip install opencv-python")
os.system("pip install torch")
import gradio as gr
from PIL import Image
import torch

  
os.system('wget https://github.com/JingyunLiang/SwinIR/releases/download/v0.0/003_realSR_BSRGAN_DFO_s64w8_SwinIR-M_x4_GAN.pth -P experiments/pretrained_models')

def inference(img):
    os.system('mkdir test')
    basewidth = 256
    wpercent = (basewidth/float(img.size[0]))
    hsize = int((float(img.size[1])*float(wpercent)))
    img = img.resize((basewidth,hsize), Image.ANTIALIAS)
    img.save("test/1.jpg", "JPEG")
    os.system('python main_test_swinir.py --task real_sr --model_path experiments/pretrained_models/003_realSR_BSRGAN_DFO_s64w8_SwinIR-M_x4_GAN.pth --folder_lq test --scale 4')
    return 'results/swinir_real_sr_x4/1_SwinIR.png'
        
title = ""
description = ""
article = ""

examples=[['ETH_LR.png']]
gr.Interface(
    inference, 
    [gr.inputs.Image(type="pil", label="Input")], 
    gr.outputs.Image(type="file", label="Output"),
    title=title,
    description=description,
    article=article,
    enable_queue=True,
    css="Footer {visibility: hidden}",
    examples=examples
    ).launch(debug=True)