Thomas Chardonnens commited on
Commit
4c7366a
1 Parent(s): c8a2e23

reshape to 32

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -150,14 +150,14 @@ def encrypt(user_id, input_image):
150
 
151
  import numpy as np
152
  # Resize image if necessary
153
- if input_image.shape != (224, 224, 3):
154
  input_image_pil = Image.fromarray(input_image)
155
- input_image_pil = input_image_pil.resize((224, 224))
156
  input_image = np.array(input_image_pil)
157
 
158
  # Convert to grayscale and reshape to (1, 1, 224, 224)
159
  input_image = np.mean(input_image, axis=2).astype(np.float32)
160
- input_image = input_image.reshape(1, 1, 224, 224)
161
 
162
  # Scale values to 12-bit range (-2048 to 2047)
163
  input_image = (input_image / 255.0 * 4095 - 2048).astype(np.int16)
 
150
 
151
  import numpy as np
152
  # Resize image if necessary
153
+ if input_image.shape != (32, 32, 3):
154
  input_image_pil = Image.fromarray(input_image)
155
+ input_image_pil = input_image_pil.resize((32, 32))
156
  input_image = np.array(input_image_pil)
157
 
158
  # Convert to grayscale and reshape to (1, 1, 224, 224)
159
  input_image = np.mean(input_image, axis=2).astype(np.float32)
160
+ input_image = input_image.reshape(1, 1, 32, 32)
161
 
162
  # Scale values to 12-bit range (-2048 to 2047)
163
  input_image = (input_image / 255.0 * 4095 - 2048).astype(np.int16)