Skip to content

pavan98765/facial_recognition

Repository files navigation

Facial Recognition System

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.

Results

fr

fr

fr

Alt text Alt text
Alt text Alt text
Alt text

Quick Start

  1. Clone the repository: Get started by cloning this repository to your local machine.

  2. 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

Usage Guide

Dataset Setup:

Get started with your data in two easy steps:

  1. 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.

  1. Or Use the provided default dataset:
  • A celebrities dataset is included for quick testing.

Please refer to the folder structure below for more details.

Training Your Model

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.

Testing and Validation

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

Real-Time Recognition

For live facial recognition using a webcam or video feed:

python detector.py --live

Evaluation

Evaluate the model on the test dataset:

python detector.py --evaluate

Repo/Dataset format:

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

Scripts Overview:

  1. 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!

  2. image_process.py: 'image_process.py' processes images from the validation folder, predicts on them, and stores the results in the output folder.

  3. 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.

  4. video_process_tracking.py:video_process_tracking.py is an enhanced version of video_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.
  1. 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.

  2. 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).
  3. 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!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published