tomaseo2022 commited on
Commit
518cfb2
1 Parent(s): 49569aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -12
app.py CHANGED
@@ -1,6 +1,4 @@
1
  import os
2
- os.system("conda install pytorch torchvision -c pytorch")
3
- os.system("pip install torch")
4
  import gradio as gr
5
  from PIL import Image
6
  import torch
@@ -16,24 +14,20 @@ def inference(img):
16
  img = img.resize((basewidth,hsize), Image.ANTIALIAS)
17
  img.save("test/1.jpg", "JPEG")
18
  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')
19
-
20
- # Load the output image file as an Image object
21
- output_img = Image.open('results/swinir_real_sr_x4/1_SwinIR.png')
22
-
23
- # Return the output image
24
- return output_img
25
 
26
  title = "SwinIR"
27
  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."
28
  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>"
29
 
30
-
31
  gr.Interface(
32
  inference,
33
  [gr.inputs.Image(type="pil", label="Input")],
34
- gr.outputs.Image(type="pil", label="Output"),
35
  title=title,
36
  description=description,
37
  article=article,
38
- enable_queue=True
39
- ).launch(debug=True)
 
 
1
  import os
 
 
2
  import gradio as gr
3
  from PIL import Image
4
  import torch
 
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)