File size: 1,949 Bytes
bd78b3e
 
 
a3c9a90
bd78b3e
 
 
 
1f1dd59
bd78b3e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bf38a34
bd78b3e
8ab1010
3676944
 
 
 
bd78b3e
 
 
4d36234
 
bd78b3e
3676944
 
 
 
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
37
38
39
40
41
import os
import gradio as gr
from PIL import Image
# import torch


os.system(
    'wget https://github.com/FanChiMao/SUNet/releases/download/0.0/AWGN_denoising_SUNet.pth -P experiments/pretrained_models')
##

def inference(img):
    os.system('mkdir test')
    #basewidth = 512
    #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.png", "PNG")
    os.system(
        'python main_test_SUNet.py --input_dir test --weights experiments/pretrained_models/AWGN_denoising_SUNet.pth')
    return 'result/1.png'


title = "SUNet: Swin Transformer with UNet for Image Denoising"
description = "Gradio demo for SUNet. SUNet has competitive performance results in terms of quantitative metrics and visual quality. See the paper and project page for detailed results below. Here, we provide a demo for AWGN image denoising. To use it, simply upload your image, or click one of the examples to load them. Reference from: https://huggingface.co/akhaliq"
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2202.14009' target='_blank'>SUNet: Swin Transformer with UNet for Image Denoising</a> | <a href='https://github.com/FanChiMao/SUNet' target='_blank'>Github Repo</a></p> <center><img src='https://visitor-badge.glitch.me/badge?page_id=52Hz_SUNet_AWGN_denoising' alt='visitor badge'></center>"

examples = [['set5/baby.png'], ['set5/bird.png'],['set5/butterfly.png'],['set5/head.png'],['set5/woman.png']]
interface = gr.Interface(
    fn=inference,
    inputs=gr.Image(type="pil", label="Input"),  # Updated to gr.Image
    outputs=gr.Image(type="pil", label="Output"),  # Updated to gr.Image
    title=title,
    description=description,
    article=article,
    allow_flagging=False,
    allow_screenshot=False,
    examples=examples
)

# Launch the interface with debugging
interface.launch(debug=True)