PavanKumarD's picture
Update app.py
03e91c8 verified
Raw History Blame Contribute Delete
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()