Skip to content

This project is a face recognition pipeline that allows for the detection and matching of faces against a pre-existing dataset.

Notifications You must be signed in to change notification settings

QoyyumO/Face-ID

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Face Recognition Pipeline

This project is a face recognition pipeline that allows for the detection and matching of faces against a pre-existing dataset. The system uses DeepFace, a powerful deep learning library for facial recognition tasks, and supports multiple detector backends.

Project Overview

The project consists of three main components:

  1. Face Detection: Identifies faces in images using a detection backend (e.g., OpenCV).
  2. Face Matching: Matches detected faces against a dataset of images.
  3. Pipeline Execution: Orchestrates the processing of new images to detect and match faces.

Directory Structure

project_root/
|-- datasets/                # Dataset of existing face images for matching
|-- new_images/             # Folder containing new images to process
|-- main.py                 # Main script to run the pipeline
|-- face_detection.py       # Module for face detection
|-- face_matching.py        # Module for face matching
|-- requirements.txt        # Python dependencies

Requirements

  • Python 3.7+
  • Required libraries (install via requirements.txt):
pip install -r requirements.txt

Key Dependencies:

  • deepface
  • opencv-python

Usage

Running the Pipeline

  1. Add new images to the new_images/ folder.
  2. Run the main script:
python main.py

Expected Output

The script will:

  • Detect faces in the images located in the new_images/ folder.
  • Match detected faces against the dataset in the dataset/ folder.
  • Print the results, including matched identities or Unknown if no match is found.

Sample Output

For example, when processing new1.jpg in new_images/, the script might print:

Processing image: new1.jpg
  🔍 Matching face 1 in new1.jpg...
    ✅ Face 1 matches: person1.jpg
Processing image: new2.jpg
  ⚠ No faces detected in new2.jpg.

Methodology

The pipeline works as follows:

  1. Face Detection:

    • Faces are detected in the input images using the OpenCV backend of DeepFace. This involves preprocessing, such as alignment and resizing, to improve detection accuracy.
  2. Feature Extraction:

    • Detected faces are passed through a pre-trained model (DeepFace) to extract embeddings (numerical feature representations of faces).
  3. Face Matching:

    • The extracted embeddings are compared against embeddings from the dataset using similarity metrics (cosine similarity).
  4. Thresholding:

    • A match is considered valid if the distance between embeddings is below a pre-defined threshold (0.68).

Dataset and Pre-trained Models

Dataset

  • The dataset consists of labeled images stored in the dataset/ folder.
  • Each subfolder corresponds to a unique individual, e.g.,:
    dataset/
    |-- person1/
        |-- 1.jpg
        |-- 2.jpg
    |-- person2/
        |-- 1.jpg
        |-- 2.jpg
    
  • Ensure that images are clear and contain identifiable faces.

Pre-trained Models

  • The system uses DeepFace’s default pre-trained models (e.g., VGG-Face, Facenet) for feature extraction.
  • These models are fine-tuned for face recognition tasks and are downloaded automatically by DeepFace if not already present.

Results and Testing Accuracy

Results

  • For a given image, the pipeline outputs the best match or "Unknown" if no match is found.

Testing Accuracy

  • The pipeline was tested with a small dataset of 10 individuals, each with 5 images. Results showed:
    • Detection Accuracy: 90%
    • Matching Accuracy: 85% (with a threshold of 0.68).

To improve accuracy, consider increasing the dataset size and using higher-quality images.

Code Documentation

main.py

This is the entry point of the project. It orchestrates the detection and matching of faces for new images.

face_detection.py

Handles face detection using DeepFace and OpenCV.

face_matching.py

Handles matching detected faces against the dataset.

Error Handling

  • No Faces Detected: The system will log a message and skip the image.

  • Matching Errors: If no match is found or an error occurs, the system returns Unknown for the face.

Future Improvements

  1. Enhanced Detection:

    • Add support for camera usage
    • Improve preprocessing of images to handle different lighting and orientations.
  2. Batch Processing:

    • Process multiple images simultaneously to improve efficiency.
  3. Interactive Reports:

    • Generate a summary report (e.g., CSV or HTML) of the matches.

Contact

For questions or suggestions, please reach out to the project maintainer.

About

This project is a face recognition pipeline that allows for the detection and matching of faces against a pre-existing dataset.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages