Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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
|
| 36 |
-
image = cv2.
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
image =
|
| 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):
|