odontathon_chest_xray / application.py
ckauth's picture
Dominik's gradio
55a645c
raw
history blame
565 Bytes
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",
)
demo.launch()