akshitagupta15june / Face-X

Demonstration of different algorithms and operations on faces. Star the repo⭐
https://discord.gg/QapWBRZbVe
MIT License
726 stars 598 forks source link

Facial features comparison [GSSoC'23 Project Request] #1475

Open Bhumika79 opened 1 year ago

Bhumika79 commented 1 year ago

When two faces are recognized they can be compared on the basis of facial features, this can also be used for comparing a face without a mask and a face with a mask in the case of security, attendance aspects etc.

github-actions[bot] commented 1 year ago

Hello @Bhumika79, Thank you for generating an issue to this project! Please wait while we get back to you.

Ayushlion8 commented 1 year ago

Sounds interesting, would like to contribute to this together... So please assign it to me combined.. @akshitagupta15june @072arushi

Ayushlion8 commented 1 year ago

@Bhumika79 can we discuss on this..

Bhumika79 commented 1 year ago

@Ayushlion8 yes we can discuss the same here.

Ayushlion8 commented 1 year ago

@Bhumika79 So, what should be the roadmap for this project like what all libraries we'll be using and all that stuff... Let's divide the work and finish it fast :)

Bhumika79 commented 1 year ago

@Ayushlion8 I have done some research, and the roadmap will be like that, also I have mentioned some code snippets to provide a general outline of how the libraries can be used for different tasks.

  1. Data Collection: Collect a dataset of facial images with labeled identities for training and evaluation purposes.
  2. Preprocessing and Feature Extraction: Library: OpenCV, dlib, face_recognition _impimport cv2 import dlib import face_recognition

Load an image using OpenCV

image = cv2.imread("image.jpg")

Convert the image to RGB

rgb_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

Detect faces in the image

face_locations = face_recognition.face_locations(rgb_image)

Align faces and extract landmarks

face_landmarks = face_recognition.face_landmarks(rgb_image, face_locations) ort cv2 import dlib import face_recognition

Load an image using OpenCV

image = cv2.imread("image.jpg")

Convert the image to RGB

rgb_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

Detect faces in the image

face_locations = face_recognition.face_locations(rgb_image)

Align faces and extract landmarks

face_landmarks = face_recognition.face_landmarks(rgb_image, facelocations)

  1. Feature Representation and Comparison: Library: face_recognition, scikit-learn

_import face_recognition from sklearn.metrics.pairwise import euclidean_distances

Extract face encodings

face_encodings = face_recognition.face_encodings(rgb_image, face_locations)

Compare face encodings using Euclidean distance

distances = euclidean_distances(face_encodings, knownencodings)

  1. Training and Model Development: Library: scikit-learn, PyTorch, TensorFlow, Keras

_from sklearn.svm import SVC from sklearn.model_selection import train_test_split

Split data into training and testing sets

X_train, X_test, y_train, y_test = train_test_split(face_encodings, labels, test_size=0.2)

Train a Support Vector Machine (SVM) classifier

svm = SVC() svm.fit(X_train, y_train)

Evaluate the classifier

accuracy = svm.score(X_test, ytest)

  1. Testing and Evaluation: Evaluate the trained model using accuracy, precision, recall, and F1-score metrics.

  2. Deployment and Integration: Integrate the facial recognition functionality into the Face-X project, such as creating an API endpoint.