Spaces:
Runtime error
Runtime error
medbenhasan
commited on
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from huggingface_hub import from_pretrained_fastai
|
3 |
+
|
4 |
+
# Load the model from Hugging Face Hub
|
5 |
+
learn = from_pretrained_fastai("hugginglearners/brain-tumor-detection-mri")
|
6 |
+
|
7 |
+
# Define the prediction function
|
8 |
+
def predict(img):
|
9 |
+
# Assuming input is an image, convert it into the format required by the model
|
10 |
+
pred_class, _, probs = learn.predict(img)
|
11 |
+
return {str(pred_class): float(probs.max())}
|
12 |
+
|
13 |
+
# Create the Gradio interface
|
14 |
+
iface = gr.Interface(fn=predict, inputs="image", outputs="label",
|
15 |
+
title="Brain Tumor Detection",
|
16 |
+
description="Upload an MRI scan to detect brain tumors")
|
17 |
+
|
18 |
+
# Launch the interface
|
19 |
+
iface.launch()
|