danhtran2mind commited on
Commit
798a218
·
verified ·
1 Parent(s): 584e3d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
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 numpy array and normalize
32
- img = input_img.convert("RGB")
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, ...] # add batch dimension
36
- print("img_array shpae: ", 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
-
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 = """