File size: 868 Bytes
6c272d3
 
 
 
 
3abdaaf
 
6c272d3
 
 
 
 
3abdaaf
 
6c272d3
 
 
 
 
 
 
 
 
 
 
 
 
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
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()