Skip to content

Commit

Permalink
checked and verified endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeshkatakam committed May 28, 2024
1 parent 423d671 commit 8cad9ff
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*.so
*.dylib

**/__pycache__/
# Ignore build output directories
/bin/
/build/
Expand Down
13 changes: 9 additions & 4 deletions src/api/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from werkzeug.utils import secure_filename
from face_recognition_model import FaceRecognizer
from preprocessing import Preprocessor
from search_embeddings import Search_Embeddings
import mysql.connector
import cv2
import numpy as np
Expand Down Expand Up @@ -40,8 +39,10 @@ def recognize_face():

preprocessor = Preprocessor(None, 160, 160, 3)

recognizer = FaceRecognizer('src/models/weights/facenet.tflite')

script_dir = os.path.dirname(__file__) # get the directory of the current script
src_dir= os.path.dirname(script_dir)
model_path = os.path.join(script_dir, 'models/weights/facenet.tflite')
recognizer = FaceRecognizer(model_path)
img = preprocessor.face_detect(img) # Detect face
img = preprocessor.face_align(img) # Align Face
img = preprocessor.crop_face_image(img) # Crop face image
Expand Down Expand Up @@ -99,7 +100,11 @@ def register_user():
image_array = np.array(image)
# Process the image and get the embedding
preprocessor = Preprocessor(None, 160, 160, 3)
recognizer = FaceRecognizer('src/models/weights/facenet.tflite')
script_dir = os.path.dirname(__file__) # get the directory of the current script
src_dir= os.path.dirname(script_dir)
model_path = os.path.join(script_dir, 'models/weights/facenet.tflite')
recognizer = FaceRecognizer(model_path)


img = preprocessor.face_detect(image_array) # Detect face
img = preprocessor.face_align(img) # Align face
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/api/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def face_align(self, image):
dx = right_eye[0] - left_eye[0]
angle = np.degrees(np.arctan2(dy, dx))
# Rotate the image to align the eyes horizontally
M = cv2.getRotationMatrix2D(((left_eye[0] + right_eye[0]) // 2, (left_eye[1] + right_eye[1]) // 2), angle, 1)
M = cv2.getRotationMatrix2D((int((left_eye[0] + right_eye[0]) // 2), int((left_eye[1] + right_eye[1]) // 2)), angle, 1)
image = cv2.warpAffine(image, M, (self.width, self.height))
return image

Expand Down

0 comments on commit 8cad9ff

Please sign in to comment.