Optimized for real case uses, as Tkinter based projects #18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The class FaceRecognition is designed for performing face recognition tasks using deep learning techniques. Here's a brief overview of how it works:
Initialization: Upon instantiation, it sets up paths for storing embeddings, recognizers, and label encoders. It also loads necessary pre-trained models for face detection and embedding extraction.
Dataset Preparation: It provides methods to create a directory for a user and implement a dataset for face recognition. The create_directory method creates a directory for a specific user, while implement_dataset captures images from a camera and saves them in the user's directory.
Feature Extraction: The extract method extracts facial embeddings from the dataset using a pre-trained deep learning model. It detects faces in images, extracts facial regions, and computes embeddings.
Model Training: The train method trains a support vector machine (SVM) classifier using the extracted facial embeddings. It serializes the trained model and label encoder for later use in recognition.
Face Recognition: The recognition method performs real-time face recognition using the trained SVM classifier. It captures frames from a camera, detects faces, extracts embeddings, and classifies them using the trained model. If the confidence score for a prediction is high enough, it returns the recognized name along with the confidence percentage.
Overall, this class encapsulates the entire pipeline for face recognition, including dataset preparation, feature extraction, model training, and real-time recognition.
Optimised to use in UI projects