Skip to content

HieuNTg/FaceReg

Repository files navigation

FaceReg - Real-Time Face Recognition System

A face recognition application built with MTCNN + InceptionResnetV1 (FaceNet) and deployed via Streamlit. Supports image, video, and real-time face recognition with dynamic face enrollment.

Architecture

Input (Image / Video / Camera)
        |
        v
  +-----------+       +-------------------+       +------------------+
  |   MTCNN   | ----> | InceptionResnetV1 | ----> | Euclidean Match  |
  | Detection |       |  512-d Embedding  |       | Threshold = 2.0  |
  +-----------+       +-------------------+       +------------------+
        |                                                |
   Bounding Box                                    Name + Confidence

Features

Feature Description
Image Recognition Upload an image and identify faces
Video Recognition Process MP4 videos with face detection overlay
Real-Time Recognition Live camera feed recognition
Face Enrollment Train new faces via video upload or webcam
Unknown Detection Identifies unknown persons (distance > 2.0)

Tech Stack

  • Deep Learning: PyTorch, FaceNet-PyTorch (MTCNN + InceptionResnetV1)
  • Web Framework: Streamlit, Streamlit-WebRTC
  • Computer Vision: OpenCV
  • ML Evaluation: Scikit-learn (SVM comparison in notebooks)
  • Deployment: Docker

Demo & Results

Processing Pipeline

Image → MTCNN Detection → InceptionResnetV1 Encoding → Euclidean Matching → Output

Pipeline

Recognition Results

Image Recognition Video Recognition
Image mode Video mode
Upload image → detect & identify face Process video frames with bounding box overlay

Performance

Metric Value
Accuracy 97% on 31-class celebrity dataset
Embedding Dim 512-d vectors
Pre-training VGGFace2
Train/Test Split 70% / 30%
Dataset 2,562 images across 31 classes (Kaggle)

Project Structure

FaceReg/
├── app.py                          # Entry point
├── src/
│   ├── core/
│   │   └── face_engine.py          # Face detection, encoding & matching
│   └── ui/
│       ├── styles.py               # Custom CSS styling
│       └── pages.py                # Streamlit page functions
├── models/
│   ├── vector_face.pth             # Pre-trained face embeddings
│   └── name_face.npy               # Face labels (31 classes)
├── notebooks/
│   ├── euclidean_distance.ipynb    # Euclidean distance approach
│   └── svm_classifier.ipynb        # SVM classifier approach
├── assets/                          # Static files (images, gifs)
├── experiments/
│   └── app_webrtc.py               # WebRTC experimental version
├── Dockerfile
├── requirements.txt
└── README.md

Quick Start

# Clone the repository
git clone https://github.com/HieuNTg/FaceReg.git
cd FaceReg

# Install dependencies
pip install -r requirements.txt

# Run the app
streamlit run app.py

Docker

docker build -t facereg .
docker run -p 8501:8501 facereg

Open http://localhost:8501 in your browser.

Training Notebooks

Notebook Approach Details
notebooks/euclidean_distance.ipynb Euclidean Distance Distance-based matching with averaged embeddings
notebooks/svm_classifier.ipynb SVM Classifier Support Vector Machine on 512-d embeddings

Future Improvements

  • Liveness Detection - Anti-spoofing with face mesh / blink detection
  • Multi-Face Recognition - Detect and identify all faces in a frame simultaneously
  • Cosine Similarity - Alternative distance metric for better embedding comparison
  • Attendance System - Automated check-in/check-out with reporting
  • Edge Deployment - ONNX/TensorRT conversion for Raspberry Pi / Jetson Nano
  • Vector Database - Milvus/Pinecone for scalable face search

About

Real-time face recognition system using MTCNN + InceptionResnetV1 (FaceNet) with Streamlit web UI. Supports image, video & live camera recognition with dynamic face enrollment. 97% accuracy on 31-class dataset.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors