52Hz commited on
Commit
d430426
1 Parent(s): 897d771

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from PIL import Image
4
+ import torch
5
+
6
+ os.system(
7
+ 'wget https://github.com/TentativeGitHub/SRMNet/releases/download/0.0/AWGN_denoising_SRMNet.pth -P experiments/pretrained_models')
8
+
9
+
10
+ def inference(img):
11
+ os.system('mkdir test')
12
+ basewidth = 256
13
+ wpercent = (basewidth / float(img.size[0]))
14
+ hsize = int((float(img.size[1]) * float(wpercent)))
15
+ img = img.resize((basewidth, hsize), Image.ANTIALIAS)
16
+ img.save("test/1.jpg", "JPEG")
17
+ os.system(
18
+ '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')
19
+ return 'results/swinir_real_sr_x4/1_SwinIR.png'
20
+
21
+
22
+ title = "Selective Residual M-Net (SRMNet)"
23
+ 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."
24
+ 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>"
25
+
26
+ examples = [['ETH_LR.png']]
27
+ gr.Interface(
28
+ inference,
29
+ [gr.inputs.Image(type="pil", label="Input")],
30
+ gr.outputs.Image(type="file", label="Output"),
31
+ title=title,
32
+ description=description,
33
+ article=article,
34
+ enable_queue=True,
35
+ examples=examples
36
+ ).launch(debug=True)