Download app.py from PavanKumarD/Brain-Tumor-classification: direct link, hf CLI and curl.
- Browser
- Download file 576 Bytes
-
https://huggingface.co/spaces/PavanKumarD/Brain-Tumor-classification/resolve/main/app.py
- Command line
-
hf download hf://spaces/PavanKumarD/Brain-Tumor-classification/app.py
-
curl -L -o app.py https://huggingface.co/spaces/PavanKumarD/Brain-Tumor-classification/resolve/main/app.py
576 Bytes
| import gradio as gr | |
| from inference import predict | |
| def gradio_predict(image): | |
| with open(image, "rb") as f: | |
| result = predict(f.read()) # returns {"class": "meningioma", "confidence": 0.97} | |
| return {result["class"]: float(result["confidence"])} # Gradio Label expects {label: confidence} | |
| iface = gr.Interface( | |
| fn=gradio_predict, | |
| inputs=gr.Image(type="filepath", label="Upload MRI Image"), | |
| outputs=gr.Label(num_top_classes=1, label="Prediction"), | |
| title="Brain Tumor MRI Image Classification" | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() | |