Skip to content

eslam-adel25/FaceRecognitionProject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 Real-Time Face Recognition System

A real-time face recognition system built using PyTorch and OpenCV. The system detects faces from a live camera feed, extracts deep facial embeddings, and identifies individuals by comparing them with a stored database.


🚀 Features

  • Real-time face detection using MTCNN
  • Deep feature extraction using FaceNet (InceptionResnetV1)
  • Face recognition using Euclidean Distance
  • Multi-face support in a single frame
  • Unknown face detection with alert
  • Live statistics (Total / Known / Unknown)
  • Real-time timestamp display

🧩 System Pipeline

Camera → Face Detection → Face Alignment → Embedding Extraction → Comparison → Decision → Display

Step-by-step:

  1. Capture frame using OpenCV
  2. Detect faces using MTCNN
  3. Align and preprocess faces
  4. Extract embeddings using FaceNet
  5. Compare embeddings with database
  6. Identify person or label as "Unknown"

🛠️ Technologies Used

Component Technology
Framework PyTorch
Face Detection MTCNN
Feature Extraction FaceNet (InceptionResnetV1)
Video Processing OpenCV
Math Operations NumPy
Data Storage Pickle

🧠 Core Concept

The system is based on Deep Metric Learning, not traditional classification.

Instead of predicting classes, the model:

  • Converts faces → embeddings (vectors)
  • Compares similarity using distance

Distance Formula:

d = √Σ(xᵢ - yᵢ)²

  • Small distance → Same person
  • Large distance → Different person

📁 Project Structure

FaceRecognitionProject/

├── build_database.py ├── recognize_realtime.py ├── utils.py

├── Known_faces/ ├── database/

└── requirements.txt


⚙️ Installation

pip install -r requirements.txt


▶️ Usage

1. Build the database

python build_database.py

2. Run real-time recognition

python recognize_realtime.py


📌 Notes

  • Uses pretrained models (no training required)
  • Works offline after setup
  • Accuracy depends on lighting, angle, and image quality

⚠️ Limitations

  • Performance drops in low light
  • Sensitive to occlusion (mask, glasses)
  • CPU execution may be slower

🚀 Future Improvements

  • GPU acceleration
  • Replace FaceNet with ArcFace
  • Use Cosine Similarity
  • Add Face Tracking
  • Optimize search using FAISS

🎯 Key Takeaway

This project demonstrates how to build a complete real-time face recognition pipeline by combining Computer Vision, Deep Learning, and Metric Learning into a practical system.

About

Real-time face recognition system using PyTorch and OpenCV. Detects faces with MTCNN, extracts embeddings using FaceNet, and identifies people by comparing with a stored database using Euclidean distance.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages