Skip to content

VedantModhave/Face_Recognition_System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Face Recognition System

This repository provides a PyTorch implementation of RetinaFace: Single-stage Dense Face Localisation in the Wild and a pipeline for face detection and recognition using Facenet512 ONNX and PyTorch.

It uses the Facenet512 model for face recognition and RetinaFace for face detection.

Features

  • Face detection using RetinaFace (ResNet50 or MobileNet0.25 backbone)
  • Face recognition using FaceNet512 (ONNX)
  • Video processing to find and timestamp appearances of a reference face

Folder Structure

Pytorch_Retinaface/
│
├── face.py                
├── requirements.txt       
├── facenet512.onnx        
├── weights/
│   └── Resnet50_Final.pth 
├── data/
│   └── config.py          
├── models/
│   └── retinaface.py      
├── layers/
│   └── functions/
│       └── prior_box.py
├── utils/
│   └── box_utils.py
├── examples/                
│   ├── 4.jpeg
│   ├── 4.mp4
│   └── ...
└── README.md

Installation

  1. Clone the repository

    git clone https://github.com/VedantModhave/Face_Recognition_System
    cd Face_Recognition_System
  2. Install dependencies

    pip install -r requirements.txt
  3. Download Pretrained Weights and ONNX Model

    • Create the weights folder if it does not exist:
      mkdir weights
    • Download the following files from this Google Drive folder:
      • Resnet50_Final.pth → Place inside the weights/ folder.
      • facenet512.onnx → Place in the root directory (Face_Recognition_System/`).

Usage

1. Prepare Your Data

  • Place your reference image (e.g., examples/4.jpeg) and video file (e.g., examples/4.mp4) in the examples/ folder.

2. Run Face Recognition

To use GPU (default, if available):

python face.py --image examples/4.jpeg --video examples/4.mp4
  • The script will automatically use GPU if a CUDA-capable device and CUDA-enabled PyTorch are installed.

To force CPU usage:

On Windows:

set CUDA_VISIBLE_DEVICES=
python face.py --image examples/4.jpeg --video examples/4.mp4

On Linux/macOS:

CUDA_VISIBLE_DEVICES= python face.py --image examples/4.jpeg --video examples/4.mp4

Or, you can edit face.py and set:

DEVICE = "cpu"
  • --image: Path to the reference face image.
  • --video: Path to the video file to process.

3. Output

  • The script will print:
    • Number of frames where the reference face was detected
    • Average detection probability
    • First and last appearance timestamps
    • All appearance intervals in the video

Notes

  • By default, RetinaFace uses the ResNet50 backbone. You can change this in face.py by modifying RETINAFACE_NETWORK.
  • Detection and recognition thresholds can be adjusted in face.py for your use case.
  • For best results, use clear, frontal reference images.

References

About

A PyTorch-based face detection and recognition system that uses RetinaFace and Facenet512 models to identify faces in images and videos, featuring a complete data pipeline and easy video timestamping of appearances.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages