tomaseo2022 commited on
Commit
c9a49d0
1 Parent(s): c0f40bc

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.png'
18
+
19
+ title = "SwinIR"
20
+ description = "Gradio demo for SwinIR. SwinIR achieves state-of-the-art performance on six tasks: image super-resolution (including classical, lightweight and real-world image super-resolution), image denoising (including grayscale and color image denoising) and JPEG compression artifact reduction. See the paper and project page for detailed results below. Here, we provide a demo for real-world image SR.To use it, simply upload your image, or click one of the examples to load them."
21
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2108.10257' target='_blank'>SwinIR: Image Restoration Using Swin Transformer</a> | <a href='https://github.com/JingyunLiang/SwinIR' target='_blank'>Github Repo</a></p>"
22
+
23
+ examples=[['ETH_LR.png']]
24
+ gr.Interface(
25
+ inference,
26
+ [gr.inputs.Image(type="pil", label="Input")],
27
+ gr.outputs.Image(type="file", label="Output"),
28
+ title=title,
29
+ description=description,
30
+ article=article,
31
+ enable_queue=True,
32
+ examples=examples
33
+ ).launch(debug=True)