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/Lowlight.pth") # 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 NAFNet: Nonlinear Activation Free Network for Image Restoration. 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 = "

Simple Baselines for Image Restoration | NAFSSR: Stereo Image Super-Resolution Using NAFNet | Github Repo

" ''' 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) '''