BrainScanAI / app.py
medbenhasan's picture
Create app.py
6a87acd verified
raw
history blame
684 Bytes
import gradio as gr
from huggingface_hub import from_pretrained_fastai
# Load the model from Hugging Face Hub
learn = from_pretrained_fastai("hugginglearners/brain-tumor-detection-mri")
# Define the prediction function
def predict(img):
# Assuming input is an image, convert it into the format required by the model
pred_class, _, probs = learn.predict(img)
return {str(pred_class): float(probs.max())}
# Create the Gradio interface
iface = gr.Interface(fn=predict, inputs="image", outputs="label",
title="Brain Tumor Detection",
description="Upload an MRI scan to detect brain tumors")
# Launch the interface
iface.launch()