from huggingface_hub import from_pretrained_keras from PIL import Image import keras import numpy as np import os import tensorflow as tf model = keras.saving.load_model("model/model.keras") def predict(image_path): image = Image.fromarray(image_path) image = image.convert('L') image = image.resize((150, 150)) # Resize to match your model's input size img_array = np.array(image) / 255.0 # Normalize pixel values img_array = np.expand_dims(img_array, axis=0) # Add batch dimension prediction = model.predict(img_array) labels = ['Glioma', 'Meningioma', 'No tumor', 'Pituitary'] probabilities = {label: probability for label, probability in zip(labels, prediction[0])} return probabilities