ImanAmran commited on
Commit
cc07a1a
·
1 Parent(s): d25a6fa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -4,7 +4,7 @@ import numpy as np
4
  import cv2
5
  import os
6
  from scipy.spatial.distance import cosine
7
- from tensorflow.keras.applications import resnet
8
  from tensorflow.keras import layers, Model
9
 
10
  def create_embedding_model():
@@ -32,8 +32,15 @@ RECOGNITION_THRESHOLD = 0.1 # Adjust as needed
32
 
33
  # Preprocess the image
34
  def preprocess_image(image):
35
- image = cv2.resize(image, (200, 200)) # Resize image to 200x200
36
- image = tf.keras.applications.resnet50.preprocess_input(image)
 
 
 
 
 
 
 
37
  return np.expand_dims(image, axis=0)
38
 
39
  # Generate embedding
 
4
  import cv2
5
  import os
6
  from scipy.spatial.distance import cosine
7
+ from tensorflow.keras.models import load_model
8
  from tensorflow.keras import layers, Model
9
 
10
  def create_embedding_model():
 
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