Spaces:
Runtime error
Runtime error
Ahsen Khaliq
commited on
Commit
·
9d75797
1
Parent(s):
94a2bc1
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from PIL import Image
|
| 4 |
+
import torch
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
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')
|
| 8 |
+
|
| 9 |
+
def inference(img):
|
| 10 |
+
os.system('mkdir test')
|
| 11 |
+
basewidth = 256
|
| 12 |
+
wpercent = (basewidth/float(img.size[0]))
|
| 13 |
+
hsize = int((float(img.size[1])*float(wpercent)))
|
| 14 |
+
img = img.resize((basewidth,hsize), Image.ANTIALIAS)
|
| 15 |
+
img.save("test/1.jpg", "JPEG")
|
| 16 |
+
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')
|
| 17 |
+
return 'results/swinir_real_sr_x4/1_SwinIR.jpg'
|
| 18 |
+
|
| 19 |
+
title = "Real-ESRGAN"
|
| 20 |
+
description = "Gradio demo for Real-ESRGAN. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
|
| 21 |
+
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2107.10833'>Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data</a> | <a href='https://github.com/xinntao/Real-ESRGAN'>Github Repo</a></p>"
|
| 22 |
+
gr.Interface(
|
| 23 |
+
inference,
|
| 24 |
+
[gr.inputs.Image(type="pil", label="Input")],
|
| 25 |
+
gr.outputs.Image(type="file", label="Output"),
|
| 26 |
+
title=title,
|
| 27 |
+
description=description,
|
| 28 |
+
article=article,
|
| 29 |
+
enable_queue=True
|
| 30 |
+
).launch(debug=True)
|