A robust, real-time face recognition system designed to accurately identify individuals even under real-world occlusions such as masks, hats, and glasses.
Powered by InsightFace (ArcFace) for state-of-the-art embedding extraction, OpenCV for low-light enhancement, and an optimized Gradio UI for zero-lag live video streaming.
Most basic face recognition projects break when faces are partially covered or under poor lighting. This project addresses those edge cases:
| Feature | Standard Face Recognition | This Project |
|---|---|---|
| 😷 Mask Detection | ❌ Fails | ✅ Robust to masks |
| 👓 Accessories | ❌ Struggles | ✅ Handles hats and glasses |
| ⚡ Video Speed | 🐢 Laggy (Blocks on inference) | ✅ Real-time (Async Background Inference) |
| 💡 Lighting | ❌ Fails in shadows | ✅ CLAHE low-light enhancement |
| 📊 Accuracy | 📉 Basic Haar Cascades / HOG | ✅ Deep Learning (buffalo_l model) |
To achieve zero-lag real-time video streaming, the application uses an asynchronous background inference pipeline:
- Live UI Stream: The Gradio web interface captures frames at 15 FPS without queuing (
queue=False), avoiding backlog buildup. - Background Inference Thread: An independent worker thread runs the heavy InsightFace deep learning model on downscaled frames.
- Instant Annotation: The UI thread instantly draws the last known bounding boxes on the current live frame, ensuring smooth video playback regardless of GPU/CPU speed.
- Embedding Caching: Embeddings are loaded into memory and cache-invalidated only via timestamp, preventing disk I/O bottlenecks.
- Deep Learning:
insightface(ArcFace /buffalo_lmodel),onnxruntime - Computer Vision:
opencv-python, CLAHE lighting enhancement - Vector Search:
scikit-learn(Cosine Similarity) - Web Interface:
gradio(v4+ compatible) - Deployment: Configured for Render.com (
render.yaml)
git clone https://github.com/snehithmthomas/Face-Recognition.git
cd Face-Recognitionpip install -r requirements.txtpython app.pyThe Gradio web interface will launch locally at http://127.0.0.1:10000.
- Register Face (Tab 1): Enter a person's name and upload 1 or more clear photos of their face.
- Live Recognition (Tab 2): Allow webcam access. The system will track and recognize registered faces in real-time.
Snehith M Thomas
- GitHub: @snehithmthomas
- LinkedIn: Snehith M Thomas