Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from PIL import Image | |
| import numpy as np | |
| def process_image(image): | |
| if image is None: | |
| return None | |
| # Convert to numpy array if it's a PIL Image | |
| if isinstance(image, Image.Image): | |
| image = np.array(image) | |
| # Display image information | |
| height, width = image.shape[:2] | |
| info = f"Image size: {width}x{height}" | |
| return image, info | |
| # Define the Gradio interface | |
| iface = gr.Interface( | |
| fn=process_image, | |
| inputs=gr.Image(type="pil"), | |
| outputs=[ | |
| gr.Image(type="numpy", label="Uploaded Image"), | |
| gr.Textbox(label="Image Information") | |
| ], | |
| title="Simple Image Uploader", | |
| description="Upload an image to display it and show basic information." | |
| ) | |
| # Launch the interface | |
| iface.launch() |