52Hz/SUNet_AWGN_denoising
12
1import os2import gradio as gr3from PIL import Image4# import torch5 6 7os.system('wget https://github.com/FanChiMao/SUNet/releases/download/0.0/AWGN_denoising_SUNet.pth -P experiments/pretrained_models')8 9def inference(img):10 # os.system('mkdir test')11 os.makedirs("test", exist_ok=True)12 #basewidth = 51213 #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.png", "PNG")17 os.system(18 'python main_test_SUNet.py --input_dir test --weights experiments/pretrained_models/AWGN_denoising_SUNet.pth')19 return 'result/1.png'20 21 22title = "SUNet: Swin Transformer with UNet for Image Denoising"23description = "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"24article = "<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>"25 26examples = [['set5/baby.png'], ['set5/bird.png'],['set5/butterfly.png'],['set5/head.png'],['set5/woman.png']]27# Create a Gradio Interface using the updated API28interface = gr.Interface(29 fn=inference,30 inputs=gr.Image(type="pil", label="Input"), # Updated to gr.Image31 outputs=gr.Image(type="pil", label="Output"), # Updated to gr.Image32 title=title,33 description=description,34 article=article,35 allow_flagging=False,36 examples=examples37)38 39# Launch the interface with debugging40interface.launch(debug=True)