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()