Omkar1872's picture
Update app.py
80b682b verified
raw
history blame contribute delete
703 Bytes
import gradio as gr
import tensorflow as tf
import numpy as np
from PIL import Image
# Load the trained model
model = tf.keras.models.load_model("brain_tumor_model.h5")
# Prediction function
def predict_tumor(image):
image = image.resize((150, 150))
image = np.expand_dims(np.array(image) / 255.0, axis=0)
prediction = model.predict(image)[0][0]
return "🧠 Tumor Detected" if prediction > 0.5 else "✅ No Tumor Detected"
# Gradio Interface
gr.Interface(
fn=predict_tumor,
inputs=gr.Image(type="pil"),
outputs="text",
title="🧠 Brain Tumor MRI Classifier",
description="Upload a brain MRI scan to detect tumor presence.",
allow_flagging="never"
).launch()