Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,7 @@ mnist_examples = [[cv2.resize(x_test[i], DIMS)] for i in range(10)]
|
|
21 |
# Function to preprocess the image
|
22 |
def preprocess_image(image):
|
23 |
if isinstance(image, Image.Image):
|
24 |
-
image = np.array(image)
|
25 |
image = cv2.resize(image, (28, 28)) # Resize to 28x28 for model input
|
26 |
image = image / 255.0
|
27 |
image = image.reshape(1, 28, 28, 1)
|
|
|
21 |
# Function to preprocess the image
|
22 |
def preprocess_image(image):
|
23 |
if isinstance(image, Image.Image):
|
24 |
+
image = np.array(image.convert('L')) # Convert to grayscale
|
25 |
image = cv2.resize(image, (28, 28)) # Resize to 28x28 for model input
|
26 |
image = image / 255.0
|
27 |
image = image.reshape(1, 28, 28, 1)
|