arianmo commited on
Commit
6c272d3
·
verified ·
1 Parent(s): 91d999f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import matplotlib.pyplot as plt
3
+ import numpy as np
4
+ from datasets import load_dataset
5
+
6
+ # Load the chest X-ray classification dataset
7
+ dataset = load_dataset("keremberke/chest-xray-classification")
8
+
9
+ def show_samples(label):
10
+ # Get samples from the dataset
11
+ images = []
12
+ for i in range(5): # Show 5 images
13
+ images.append(dataset['train'][i]['image']) # Adjust as needed
14
+
15
+ # Create a grid of images
16
+ fig, axes = plt.subplots(1, 5, figsize=(15, 5))
17
+ for ax, img in zip(axes, images):
18
+ ax.imshow(np.asarray(img)) # Convert to a format suitable for matplotlib
19
+ ax.axis('off')
20
+ plt.title(f"Label: {label}")
21
+ plt.tight_layout()
22
+ plt.show()
23
+
24
+ # Create Gradio interface
25
+ iface = gr.Interface(fn=show_samples, inputs="text", outputs="plot")
26
+ iface.launch()