sensei-ml's picture
Update model/model.py
27e200d verified
raw
history blame
574 Bytes
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.models.load_model('sensei-ml/Brain_Tumors_Classificator_CNN_Keras_Model/model')
def predict(image_path):
img = Image.open(image_path)
img = img.resize((255, 255)) # Resize to match your model's input size
img_array = np.array(img) / 255.0 # Normalize pixel values
img_array = np.expand_dims(img_array, axis=0) # Add batch dimension
predictions = model.predict(img_array)
return predictions[0]