import gradio as gr from gradio import inputs from tensorflow.keras.models import load_model from tensorflow.keras.preprocessing import image import numpy as np from keras.applications.imagenet_utils import preprocess_input # Load the model model = load_model('best_model.h5') def classify_image(inp): inp = inp.reshape((-1, 224, 224, 3)) inp = preprocess_input(inp) prediction = model.predict(inp).flatten() return {"Brain Tumor not Detected": float(prediction[0]), "Brain Tumor Detected": float(prediction[1])} image = gr.inputs.Image(shape=(224, 224)) gr.Interface(fn=classify_image, inputs=image, outputs="label").launch()