ImanAmran commited on
Commit
a4c5035
·
1 Parent(s): 68f1e27

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -10
app.py CHANGED
@@ -32,16 +32,11 @@ RECOGNITION_THRESHOLD = 0.1 # Adjust as needed
32
 
33
  # Preprocess the image
34
  def preprocess_image(image):
35
- # Resize image to match FaceNet input size (160x160)
36
- image = cv2.resize(image, (160, 160))
37
-
38
- # Normalize the image to a range of [-1, 1] as FaceNet might expect
39
- image = image.astype('float32')
40
- mean, std = image.mean(), image.std()
41
- image = (image - mean) / std
42
-
43
- # Expand dimensions to add batch size of 1
44
- return np.expand_dims(image, axis=0)
45
 
46
  # Generate embedding
47
  def generate_embedding(image):
 
32
 
33
  # Preprocess the image
34
  def preprocess_image(image):
35
+ image = cv2.resize(image, (160, 160)) # Resize image to match FaceNet input size
36
+ image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) # Convert to RGB (OpenCV loads images in BGR)
37
+ image = tf.convert_to_tensor(image) # Convert to TensorFlow tensor
38
+ image = tf.image.convert_image_dtype(image, tf.float32) # Normalize pixel values
39
+ return np.expand_dims(image, axis=0) # Add batch dimension
 
 
 
 
 
40
 
41
  # Generate embedding
42
  def generate_embedding(image):