File size: 813 Bytes
63495b1
06010a5
7c2306e
06010a5
 
 
 
 
 
 
9a7103b
7c2306e
9a7103b
06010a5
9a7103b
 
06010a5
21a3715
7c2306e
06010a5
7c2306e
06010a5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
from PIL import Image, ImageEnhance

def to_black_and_white(input_image, contrast_level):
    # Enhance contrast
    enhancer = ImageEnhance.Contrast(input_image)
    enhanced_image = enhancer.enhance(contrast_level)
    
    # Convert to grayscale
    bw_image = enhanced_image.convert("L")
    return bw_image

with gr.Blocks() as app:
    gr.Markdown("### Black and White Image Maker with Contrast Adjustment")
    with gr.Row():
        image_input = gr.Image(type="pil", label="Upload your Image")
        contrast_slider = gr.Slider(minimum=0.5, maximum=3.0, value=1.0, label="Contrast Level")
        image_output = gr.Image(type="pil", label="Black and White Image")

    image_input.change(to_black_and_white, inputs=[image_input, contrast_slider], outputs=image_output)

app.launch()