File size: 947 Bytes
1cb4716
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from PIL import Image, ImageEnhance

# Function to convert image to grayscale and adjust brightness
def process_image(image, brightness):
    # Convert the image to grayscale
    grayscale_image = image.convert("L")
    
    # Adjust the brightness
    enhancer = ImageEnhance.Brightness(grayscale_image)
    bright_image = enhancer.enhance(brightness)
    
    return bright_image

# Create a Gradio interface
iface = gr.Interface(
    fn=process_image,  # Function to process the image
    inputs=[
        gr.Image(type="pil"),  # Image input, type is PIL (Python Imaging Library)
        gr.Slider(0.1, 2.0, 1.0, label="Brightness")  # Slider to control brightness
    ],
    outputs="image",  # Output is an image
    title="Grayscale Image Processor",  # Title of the interface
    description="Upload an image, convert it to grayscale, and adjust the brightness."  # Description
)

# Launch the interface
iface.launch()