File size: 625 Bytes
55a645c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d8d1acc
55a645c
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio
from transformers import pipeline

"""Predicts the probability of pneumonia given a chest x-ray image."""


_pipeline = pipeline(task="image-classification", model="nickmuchi/vit-finetuned-chest-xray-pneumonia")

def predict(image):
  predictions = _pipeline(image)
  return {p["label"]: p["score"] for p in predictions}


demo = gradio.Interface(
    fn=predict,
    inputs=gradio.inputs.Image(label="Upload lung x-ray image", type="filepath"),
    outputs=gradio.outputs.Label(num_top_classes=2),
    title="Pneumonia Probability",
    examples = ["examples/xray1.png", "examples/xray2.jpg"]
)

demo.launch()