sensei-ml commited on
Commit
c4011fa
·
verified ·
1 Parent(s): 962d630

Update model/model.py

Browse files
Files changed (1) hide show
  1. model/model.py +4 -4
model/model.py CHANGED
@@ -5,14 +5,14 @@ import numpy as np
5
  import os
6
  import tensorflow as tf
7
 
8
- os.environ["KERAS_BACKEND"] = "tensorflow"
9
- model = keras.saving.load_model("hf://sensei-ml/Brain_Tumors_Classificator_CNN_Keras_Model")
10
 
11
 
12
  def predict(image_path):
13
  image = Image.fromarray(image_path)
14
- image = image.convert('L')
15
- image = image.resize((150, 150)) # Resize to match your model's input size
16
  img_array = np.array(image) / 255.0 # Normalize pixel values
17
  img_array = np.expand_dims(img_array, axis=0) # Add batch dimension
18
  prediction = model.predict(img_array)
 
5
  import os
6
  import tensorflow as tf
7
 
8
+ os.environ['KERAS_BACKEND'] = 'tensorflow'
9
+ model = keras.saving.load_model('hf://sensei-ml/Brain_Tumors_Classificator_CNN_Keras_Model')
10
 
11
 
12
  def predict(image_path):
13
  image = Image.fromarray(image_path)
14
+ image = image.convert('L') # Use grayscale images
15
+ image = image.resize((150, 150)) # Resize to 150 x 150 px.
16
  img_array = np.array(image) / 255.0 # Normalize pixel values
17
  img_array = np.expand_dims(img_array, axis=0) # Add batch dimension
18
  prediction = model.predict(img_array)