Spaces:
Sleeping
Sleeping
import gradio as gr | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from datasets import load_dataset | |
# Load the chest X-ray classification dataset with the 'full' configuration | |
dataset = load_dataset("keremberke/chest-xray-classification", "full") | |
def show_samples(label): | |
# Get samples from the dataset | |
images = [] | |
for i in range(5): # Show 5 images | |
img = dataset['train'][i]['image'] # Adjust as needed | |
images.append(img) | |
# Create a grid of images | |
fig, axes = plt.subplots(1, 5, figsize=(15, 5)) | |
for ax, img in zip(axes, images): | |
ax.imshow(np.asarray(img)) # Convert to a format suitable for matplotlib | |
ax.axis('off') | |
plt.title(f"Label: {label}") | |
plt.tight_layout() | |
plt.show() | |
# Create Gradio interface | |
iface = gr.Interface(fn=show_samples, inputs="text", outputs="plot") | |
iface.launch() | |