Spaces:
Build error
Build error
File size: 3,216 Bytes
8666c23 bf3b4b7 8666c23 a6bdd34 8666c23 bf3b4b7 8666c23 bf3b4b7 8666c23 bf3b4b7 8666c23 bf3b4b7 8666c23 ea55f52 8666c23 a162708 8666c23 bf3b4b7 8666c23 563071b bf3b4b7 2042b2b bf3b4b7 8666c23 bf3b4b7 |
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
import gradio as gr
import os
def inference(image, task):
if not os.path.exists('tmp'):
os.system('mkdir tmp')
image.save("tmp/lq_image.png", "PNG")
# if task == 'Dehazing':
# os.system("python Dehazing.py --test_path ./tmp/lq_image.png --save_path ./tmp/ --pk_path model_zoo/Haze4k.tjm")
if task == 'LLIE':
os.system("python Lowlight.py --test_path ./tmp/lq_image.png --save_path ./tmp/ --pk_path model_zoo/Low.onnx")
# if task == 'SuperResolutionx2':
# os.system("python SuperResolution.py --test_path ./tmp/lq_image.png --save_path ./tmp/ --pk_path model_zoo/SRx2.pth --scale 2")
# if task == 'SuperResolutionx3':
# os.system("python SuperResolution.py --test_path ./tmp/lq_image.png --save_path ./tmp/ --pk_path model_zoo/SRx3.pth --scale 3")
# if task == 'SuperResolutionx4':
# os.system("python SuperResolution.py --test_path ./tmp/lq_image.png --save_path ./tmp/ --pk_path model_zoo/SRx4.pth --scale 4")
# if task == 'Underwater':
# os.system("python Underwater.py --test_path ./tmp/lq_image.png --save_path ./tmp/ --pk_path model_zoo/underwater.pth")
return 'tmp/output.png'
title = "Image Enhancement and Restoration"
description = ""
article = ""
#description = "Gradio demo for <b>NAFNet: Nonlinear Activation Free Network for Image Restoration</b>. NAFNet achieves state-of-the-art performance on three tasks: image denoising, image debluring and stereo image super-resolution (SR). See the paper and project page for detailed results below. Here, we provide a demo for image denoise and deblur. To use it, simply upload your image, or click one of the examples to load them. Inference needs some time since this demo uses CPU."
#article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2204.04676' target='_blank'>Simple Baselines for Image Restoration</a> | <a href='https://arxiv.org/abs/2204.08714' target='_blank'>NAFSSR: Stereo Image Super-Resolution Using NAFNet</a> | <a href='https://github.com/megvii-research/NAFNet' target='_blank'> Github Repo</a></p>"
'''
examples = [['demo/underwater.jpg', 'Underwater'],
['demo/low.jpg', 'LLIE'],
['demo/dehaze.jpg', 'Dehazing'],
['demo/sr.png', 'SuperResolutionx2']]
'''
examples = [['demo/low.jpg', 'LLIE']]
iface = gr.Interface(
inference,
[gr.inputs.Image(type="pil", label="Input"),
gr.inputs.Radio(["LLIE"], default="LLIE", label='task'),],
gr.outputs.Image(type="file", label="Output"),
title=title,
description=description,
article=article,
enable_queue=True,
examples=examples
)
iface.launch(debug=True,enable_queue=True)
'''
iface = gr.Interface(
inference,
[gr.inputs.Image(type="pil", label="Input"),
gr.inputs.Radio(["Underwater", "LLIE", "Dehazing", "SuperResolutionx2", "SuperResolutionx3", "SuperResolutionx4"], default="Underwater", label='task'),],
gr.outputs.Image(type="file", label="Output"),
title=title,
description=description,
article=article,
enable_queue=True,
examples=examples
)
iface.launch(debug=True,enable_queue=True)
''' |