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.
- 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
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
-
Clone the repository
git clone https://github.com/VedantModhave/Face_Recognition_System cd Face_Recognition_System -
Install dependencies
pip install -r requirements.txt
-
Download Pretrained Weights and ONNX Model
- Create the
weightsfolder if it does not exist:mkdir weights
- Download the following files from this Google Drive folder:
Resnet50_Final.pth→ Place inside theweights/folder.facenet512.onnx→ Place in the root directory (Face_Recognition_System/`).
- Create the
- Place your reference image (e.g.,
examples/4.jpeg) and video file (e.g.,examples/4.mp4) in theexamples/folder.
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.
On Windows:
set CUDA_VISIBLE_DEVICES=
python face.py --image examples/4.jpeg --video examples/4.mp4On Linux/macOS:
CUDA_VISIBLE_DEVICES= python face.py --image examples/4.jpeg --video examples/4.mp4Or, you can edit face.py and set:
DEVICE = "cpu"--image: Path to the reference face image.--video: Path to the video file to process.
- 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