Sourudra commited on
Commit
b9e1827
·
verified ·
1 Parent(s): 8f9bacb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -11
app.py CHANGED
@@ -8,17 +8,10 @@ model_path = 'cnn_tumor.h5'
8
  model = tf.keras.models.load_model(model_path)
9
 
10
  def make_prediction(img, model):
11
- img = img.resize((128, 128)) # Resize the image to 128x128
12
- img = np.array(img) / 255.0 # Normalize the image
13
-
14
- # Check if the image has only one channel (grayscale)
15
- if img.ndim == 2:
16
- img = np.stack((img,)*3, axis=-1) # Convert grayscale to RGB
17
- elif img.shape[2] == 1: # If the image has a single channel
18
- img = np.concatenate([img, img, img], axis=-1) # Convert to RGB
19
-
20
- input_img = np.expand_dims(img, axis=0) # Add a batch dimension
21
- res = model.predict(input_img) # Make the prediction
22
  return res
23
 
24
  # Function to load the CSS file and apply it
 
8
  model = tf.keras.models.load_model(model_path)
9
 
10
  def make_prediction(img, model):
11
+ img = img.resize((128, 128))
12
+ img = np.array(img) / 255.0 # Normalize the image
13
+ input_img = np.expand_dims(img, axis=0)
14
+ res = model.predict(input_img)
 
 
 
 
 
 
 
15
  return res
16
 
17
  # Function to load the CSS file and apply it