import gradio as gr from tensorflow.keras.models import load_model from tensorflow.keras.preprocessing import image from keras.applications.imagenet_utils import preprocess_input import numpy as np # Load the model model = load_model('dementia.h5') def classify_image(inp): inp = inp.reshape((-1, 224, 224, 3)) inp = preprocess_input(inp) prediction = model.predict(inp).flatten() return {"Dementia not Detected": float(prediction[0]), "Dementia Detected": float(prediction[1])} # Use 'image_mode' to specify the shape image_input = gr.Image(image_mode="RGB", source="upload", shape=(224, 224)) interface = gr.Interface( fn=classify_image, inputs=image_input, outputs="label", title="DementAI", ) interface.launch()