Welcome to the Facial Recognition System repository! Our Python-based toolkit simplifies facial recognition tasks, incorporating functionalities for training, testing, validation, and real-time recognition - both with and without object tracking. Dive into our scripts for handling both image and video data effortlessly.
-
Clone the repository: Get started by cloning this repository to your local machine.
-
Installation: Before you begin, make sure you have Python 3.7 or newer installed. Install the necessary dependencies by running:
pip install -r requirements.txt
Key Dependencies:
- OpenCV (cv2) == 4.6.0.66
- face_recognition
Get started with your data in two easy steps:
- Use Your Own Data:
-
Please place your images in the correct folders:
-
training: Images for training, sorted by person or category.
-
Validataion: Images for Validation, without sorting, direct images.
-
test: Images for testing, again sorted by person or category.
- Or Use the provided default dataset:
- A celebrities dataset is included for quick testing.
Please refer to the folder structure below for more details.
To train your model, please place the images in the training/ directory with right format:
python detector.py --train
The encodings will be saved in the output folder, which can be used further.
For testing on a single image:
python detector.py --test -f path/to/test_image.jpg
To validate and process multiple images:
python detector.py --validate
For live facial recognition using a webcam or video feed:
python detector.py --live
Evaluate the model on the test dataset:
python detector.py --evaluate
face_recognizer/
│
├── output/
│
├── training/
│ └── class1/
│ ├── img_1.jpg
│ └── img_2.png
│ └── class2/
│ ├── img_1.jpg
│ └── img_2.png
|
├── test/
│ └── class_name/
│ ├── img_1.jpg
│ └── img_2.png
│
├── validation/
│ ├── image1.jpg
│ └── image2.jpg
│
├── detector.py
├── extract_faces.py
├── image_process.py
├── lite_tracking.py
├── lite.py
├── tracking.py
├── video_process_tracking.py
└── video_process.py
-
Detector.py: Detector.py is a versatile script that can perform various facial recognition tasks:
-
Training and Encoding: Train the model on input data and save encodings for future use.
-
Testing: Test on a single image to recognize faces.
-
Validation: Validate on multiple images, visualize them (use 'Q' to move to next) and save the processed images with recognized faces at validation_output.
-
Live Recognition: Perform real-time face recognition using a webcam or video feed.
-
Evaluate: Evaluate the model on the test dataset to find the accuracy!
-
-
image_process.py: 'image_process.py' processes images from the validation folder, predicts on them, and stores the results in the output folder.
-
video_process.py: 'video_process.py' takes video input, performs facial recognition on frames, and saves the output in the output folder. It only does facial recognition on the frames.
-
video_process_tracking.py:
video_process_tracking.py
is an enhanced version ofvideo_process.py
with a two-phase approach: tracking and recognition.-
Faster Tracking: This script waits for a match and seamlessly switches to the tracking phase, providing a quicker and more efficient tracking experience.
-
Improved Performance: Designed for tracking a single person,
video_process_tracking.py
optimizes the recognition process, making it faster and more suited to scenarios where tracking is a priority.
-
- Two Phases:
- Tracking Phase: Once a match is found, the script enters the tracking phase, enhancing the accuracy and speed of tracking.
- Recognition Phase: When tracking is lost, the script smoothly transitions back to recognition, ensuring continuous monitoring.
-
Lite.py: 'Lite.py' is a simplified version of 'Detector.py', focusing on real-time recognition. It loads pre-trained encodings and matches faces in a live video feed.
-
Tracking.py: Tracking.py is a script with two main phases:
- Face Recognition Phase: Recognize faces and, when a match is found, initiate tracking.
- Object Tracking Phase: Track recognized faces and store tracking data in a database file (CSV).
-
Lite_tracking.py: Lite_tracking.py is a more streamlined version of Tracking.py, emphasizing live recognition and tracking.
Feel free to explore each script for detailed instructions and usage.
Happy Recognizing!