import gradio as gr | |
# project | |
from exposure_enhancement import enhance_image_exposure | |
# inputs, fn, and ouputs | |
examples=[ | |
["demo/1.jpg"], | |
["demo/2.bmp"] | |
] | |
def enhance_image(image, gamma=0.6, lambda_=0.15, sigma=3, lime=True, bc=1, bs=1, be=1, eps=1e-3): | |
# enhance image | |
enhanced_image = enhance_image_exposure(image, gamma, lambda_, not lime, sigma=sigma, bc=bc, bs=bs, be=be, eps=eps) | |
return enhanced_image | |
def update(name): | |
return f"Welcome to Gradio, {name}!" | |
with gr.Blocks() as demo: | |
gr.Markdown("Input an image below then click **Run** or use the cached examples for quick results. For quicker processing (typically 1-2 minutes), it's suggested to use low-exposure images of 500x500 pixels.") | |
with gr.Row(): | |
inp = gr.Image(label="Input Image", type="numpy", sources=["upload"]) | |
out = gr.Image(label="Enhanced Image", type="numpy") | |
with gr.Row(): | |
btn = gr.Button("Run") | |
btn.click(fn=enhance_image, inputs=inp, outputs=out) | |
btn = gr.ClearButton() | |
with gr.Row(): | |
gr.Examples(examples=examples, inputs=inp) | |
demo.launch(share=True) | |