Spaces:
Build error
Build error
Update app.py
Browse files
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))
|
| 12 |
-
img = np.array(img) / 255.0
|
| 13 |
-
|
| 14 |
-
|
| 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
|