Spaces:
Running
Running
import os | |
import gradio as gr | |
from PIL import Image | |
os.system('wget https://github.com/FanChiMao/SRMNet-thesis/releases/download/v0.0/Deblurring_motionblur.pth -P experiments/pretrained_models') | |
os.system('wget https://github.com/FanChiMao/SRMNet-thesis/releases/download/v0.0/Dehaze_realworld.pth -P experiments/pretrained_models') | |
os.system('wget https://github.com/FanChiMao/SRMNet-thesis/releases/download/v0.0/Denoise_gaussian.pth -P experiments/pretrained_models') | |
os.system('wget https://github.com/FanChiMao/SRMNet-thesis/releases/download/v0.0/Denoise_realworld.pth -P experiments/pretrained_models') | |
os.system('wget https://github.com/FanChiMao/SRMNet-thesis/releases/download/v0.0/Deraining_raindrop.pth -P experiments/pretrained_models') | |
os.system('wget https://github.com/FanChiMao/SRMNet-thesis/releases/download/v0.0/Deraining_rainstreak.pth -P experiments/pretrained_models') | |
os.system('wget https://github.com/FanChiMao/SRMNet-thesis/releases/download/v0.0/LLEnhancement.pth -P experiments/pretrained_models') | |
os.system('wget https://github.com/FanChiMao/SRMNet-thesis/releases/download/v0.0/Retouching.pth -P experiments/pretrained_models') | |
def inference(img, model): | |
os.system('mkdir test') | |
img.save("test/1.png", "PNG") | |
if model == 'Denoising (gaussian)': | |
os.system('python main_test_SRMNet.py --input_dir test --weights experiments/pretrained_models/Denoise_gaussian.pth') | |
elif model == 'Denoising (real-world)': | |
os.system('python main_test_SRMNet.py --input_dir test --weights experiments/pretrained_models/Denoise_realworld.pth') | |
elif model == 'Deblurring (motion-blur)': | |
os.system('python main_test_SRMNet.py --input_dir test --weights experiments/pretrained_models/Deblurring_motionblur.pth') | |
elif model == 'Dehazing (dense haze)': | |
os.system('python main_test_SRMNet.py --input_dir test --weights experiments/pretrained_models/Dehaze_realworld.pth') | |
elif model == 'Deraining (rainstreak)': | |
os.system('python main_test_SRMNet.py --input_dir test --weights experiments/pretrained_models/Deraining_rainstreak.pth') | |
elif model == 'Deraining (raindrop)': | |
os.system('python main_test_SRMNet.py --input_dir test --weights experiments/pretrained_models/Deraining_raindrop.pth') | |
elif model == 'Low-light Enhancement': | |
os.system('python main_test_SRMNet.py --input_dir test --weights experiments/pretrained_models/LLEnhancement.pth') | |
elif model == 'Retouching': | |
os.system('python main_test_SRMNet.py --input_dir test --weights experiments/pretrained_models/Retouching.pth') | |
return 'result/1.png' | |
title = "[NCHU thesis] Image Restoration by Selective Residual Block on Improved Hierarchical Encoder-Decoder Networks" | |
description = "" | |
article = "<p style='text-align: center'><a href='https://' target='_blank'>Image Restoration by Selective Residual Block on Improved Hierarchical Encoder-Decoder Networks</a> | <a href='https://github.com/FanChiMao/SRMNet-thesis' target='_blank'>Github Repo</a></p> <center><img src='https://visitor-badge.glitch.me/badge?page_id=52Hz_SRMNet_thesis' alt='visitor badge'></center>" | |
examples = [['low-light.png', 'LOL'], ['low-light_2.png', 'MIT-5K']] | |
gr.Interface( | |
inference, | |
[gr.inputs.Image(type="pil", label="Input"), gr.inputs.Dropdown(choices=[ | |
'Denoising (gaussian)', | |
'Denoising (real-world)', | |
'Deblurring (motion-blur)', | |
'Dehazing (dense haze)', | |
'Deraining (rainstreak)', | |
'Deraining (raindrop)', | |
'Low-light Enhancement', | |
'Retouching', | |
], type="value", default='Denoising (gaussian)', label="model")], | |
gr.outputs.Image(type="file", label="Output"), | |
title=title, | |
description=description, | |
article=article, | |
allow_flagging=False, | |
allow_screenshot=False, | |
examples=examples | |
).launch(debug=True) |