Fixed image preprocessing for correct model input shape
Browse files
app.py
CHANGED
|
@@ -8,8 +8,8 @@ model = tf.keras.models.load_model("prescription_model.h5")
|
|
| 8 |
|
| 9 |
# Function to preprocess the uploaded image
|
| 10 |
def preprocess_image(image):
|
| 11 |
-
image = image.convert("
|
| 12 |
-
image = image.resize((
|
| 13 |
image = np.array(image) / 255.0 # Normalize
|
| 14 |
image = np.expand_dims(image, axis=0) # Add batch dimension
|
| 15 |
return image
|
|
|
|
| 8 |
|
| 9 |
# Function to preprocess the uploaded image
|
| 10 |
def preprocess_image(image):
|
| 11 |
+
image = image.convert("RGB") # Convert to grayscale
|
| 12 |
+
image = image.resize((64, 64)) # Resize to match model input
|
| 13 |
image = np.array(image) / 255.0 # Normalize
|
| 14 |
image = np.expand_dims(image, axis=0) # Add batch dimension
|
| 15 |
return image
|