| import gradio as gr | |
| from PIL import Image | |
| def transform_image(image): | |
| if image is None: | |
| return None # Indicate no image | |
| original_image = image | |
| transformed_image = image.convert('L') # Grayscale conversion | |
| return original_image, transformed_image | |
| iface = gr.Interface( | |
| fn=transform_image, | |
| inputs=gr.Image(type='pil'), # Image input type | |
| outputs=["image", "image"], # Display both original and transformed | |
| title="My Fun Image App", | |
| description="Upload an image and see a grayscale version!" | |
| ) | |
| iface.launch() |