Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -11,10 +11,12 @@ def predict(image):
|
|
11 |
# Convert image to a numpy array
|
12 |
image = np.array(image)
|
13 |
|
14 |
-
# Resize the image to the expected shape (28, 28, 3)
|
15 |
image = tf.image.resize(image, (28, 28)) # Resize to 28x28 pixels
|
16 |
-
|
17 |
-
|
|
|
|
|
18 |
|
19 |
# Normalize the image
|
20 |
image = image / 255.0
|
|
|
11 |
# Convert image to a numpy array
|
12 |
image = np.array(image)
|
13 |
|
14 |
+
# Resize the image to the expected shape (28, 28, 3) for RGB images
|
15 |
image = tf.image.resize(image, (28, 28)) # Resize to 28x28 pixels
|
16 |
+
|
17 |
+
# Check if the image is grayscale (single channel), and convert to RGB if necessary
|
18 |
+
if image.shape[-1] == 1: # If it's grayscale (single channel)
|
19 |
+
image = np.repeat(image, 3, axis=-1) # Convert grayscale to RGB by repeating the channel
|
20 |
|
21 |
# Normalize the image
|
22 |
image = image / 255.0
|