File size: 684 Bytes
6a87acd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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()