Update app.py
Browse files
app.py
CHANGED
@@ -28,16 +28,15 @@ loaded_autoencoder = tf.keras.models.load_model(
|
|
28 |
)
|
29 |
|
30 |
def process_image(input_img):
|
31 |
-
# Convert PIL Image to
|
32 |
-
img = input_img.convert("
|
33 |
-
img = img.resize((WIDTH, HEIGHT)) #
|
34 |
img_array = tf.keras.preprocessing.image.img_to_array(img) / 255.0
|
35 |
-
img_array = img_array[None,
|
36 |
-
print("img_array
|
37 |
# Run inference
|
38 |
output_array = loaded_autoencoder.predict(img_array)
|
39 |
output_img = tf.keras.preprocessing.image.array_to_img(output_array[0])
|
40 |
-
|
41 |
return output_img
|
42 |
|
43 |
custom_css = """
|
|
|
28 |
)
|
29 |
|
30 |
def process_image(input_img):
|
31 |
+
# Convert PIL Image to grayscale and resize
|
32 |
+
img = input_img.convert("L") # Convert to grayscale (single channel)
|
33 |
+
img = img.resize((WIDTH, HEIGHT)) # Adjust size as needed
|
34 |
img_array = tf.keras.preprocessing.image.img_to_array(img) / 255.0
|
35 |
+
img_array = img_array[None, ..., 0:1] # Add batch dimension and keep single channel
|
36 |
+
print("img_array shape: ", img_array.shape)
|
37 |
# Run inference
|
38 |
output_array = loaded_autoencoder.predict(img_array)
|
39 |
output_img = tf.keras.preprocessing.image.array_to_img(output_array[0])
|
|
|
40 |
return output_img
|
41 |
|
42 |
custom_css = """
|