Spaces:
Runtime error
Runtime error
| 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() | |