Building a Real-Time Face Recognition Engine with GPU Acceleration

July 20, 2025 ยท Abhishek Mukherjee

← Back to portfolio

This is a write-up of a government project: a security system for Basukinath Temple. It tracks how the engine evolved from a basic CPU-based approach into a GPU-accelerated one, and what each step actually bought us.

Phase 1: Traditional OpenCV

The first version used traditional OpenCV with Haar Cascades for detection and LBPH for recognition. It ran at around 15 FPS with 60 to 70% accuracy. That was enough to prove the idea, but festival crowds broke it. Under real load, the system simply could not keep up.

Phase 2: DeepFace on CPU

Next I brought in DeepFace models, which pushed accuracy up to 90 to 95%. The recognition quality was much better, but CPU processing was the bottleneck: roughly 70 comparisons per second. For a busy temple with multiple cameras, that throughput was not going to hold.

Phase 3: GPU Acceleration

The real jump came from moving the work onto the GPU with PyTorch CUDA. Batch comparison on the GPU took us to about 353 comparisons per second, a large multiple over the CPU path. The same models, run on the right hardware, changed what was possible.

What the Final System Does

In standard operation the system processes 10 or more faces per frame at 30 FPS, and it supports multiple temple cameras running at the same time. The architecture combines OpenCV for detection, DeepFace for embeddings, and GPU-accelerated batch comparison for matching.

Remaining Challenges

The main weakness is non-frontal faces. Accuracy is strong head-on but falls off sharply with angle: around 95% at 0 degrees, down to roughly 10% at a full 90-degree profile. That gap is the clearest opportunity for future work, through multi-angle detection models and pose estimation.

Takeaway

The biggest practical lesson was that you do not always need a new model. Leaning on pre-trained models and matching them with hardware acceleration was what made the system viable for real-world deployment.

← Back to portfolio