File size: 1,345 Bytes
238eab6
 
 
 
c075ea7
238eab6
 
 
 
 
e3a97b8
 
 
 
 
238eab6
e3a97b8
9281d9e
 
e3a97b8
5baee12
9281d9e
 
e3a97b8
 
da557de
9281d9e
 
e3a97b8
238eab6
e3a97b8
 
5f7cb1a
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
import gradio as gr
# project
from exposure_enhancement import enhance_image_exposure

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

examples=[
    ["demo/1.jpg"],
    ["demo/2.bmp"],
    ["demo/3.jpg"],
]

with gr.Blocks() as interface:
    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():
        input_image = gr.Image(label="Input Image", type="numpy", sources=["upload"], interactive=True)
        output_image = gr.Image(label="Enhanced Image", type="numpy", sources=["upload"], interactive=False)
        
    with gr.Row():
        submit_btn = gr.Button("Run")
        submit_btn.click(fn=enhance_image, inputs=input_image, outputs=output_image)
        clear_btn = gr.ClearButton(components=[input_image, output_image])
        
    with gr.Row():
        gr.Examples(examples=examples, fn=enhance_image,inputs=input_image, outputs=output_image, cache_examples=True)

if __name__ == "__main__":
    interface.launch(share=True)