A modular, research-driven face detection & recognition system with plug-and-play detectors (OpenCV, MTCNN, Dlib, face_recognition
) and a slick Gradio web UI. Built for fast iteration, real-world reliability, and clean code vibes.
face_recognition
).face_recognition
.python face-recognition-pipeline/app.py
# then open the printed local URL in your browser
You can:
Python 3.9β3.11 recommended. GPU optional (Dlib CUDA build speeds things up but CPU works).
# clone
git clone https://github.com/amitesh-maurya/face-recognition-pipeline.git
cd face-recognition-pipeline
# (optional) create venv
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
# install
pip install -U pip wheel
pip install -r requirements.txt
If thatβs too extra, stick to CPU β itβs fine for testing.
python scripts/recognize_image.py \
--image assets/samples/group.jpg \
--detector mtcnn \
--db data/embeddings/known_faces.pkl \
--threshold 0.6
python scripts/recognize_stream.py \
--source 0 \
--detector dlib_cnn \
--db data/embeddings/known_faces.pkl
# expects folder structure: data/known/<person_name>/*.jpg
python scripts/build_embeddings.py \
--images data/known \
--output data/embeddings/known_faces.pkl \
--detector face_recognition
face-recognition-pipeline/
β app.py
β requirements.txt
β
ββ core/
β ββ __init__.py
β ββ config.py
β ββ logging_crypto.py
β ββ gallery.py
β ββ face_utils.py
β ββ match.py
β ββ pipeline.py
β
ββ ui/
ββ __init__.py
ββ gradio_ui.py
[Input (image/video/webcam)]
β
βΌ
[Detector] βββΆ face boxes + landmarks
β
βΌ
[Encoder] βββΆ 128D embedding per face (Dlib ResNet)
β
βΌ
[Matcher] βββΆ identity + similarity score vs. embeddings DB
β
βΌ
[Output] βββΆ annotated frames + JSON results
opencv_haar
β lightweight, decent on frontal facesmtcnn
β solid accuracy, slower on CPUdlib_hog
β CPU-friendly, classical HOG + SVMdlib_cnn
β accurate but needs more compute (benefits from GPU)face_recognition
β convenience wrapper around dlibAll scripts accept flags; you can also use a YAML config.
Example CLI flags:
--detector {opencv_haar,mtcnn,dlib_hog,dlib_cnn,face_recognition}
--threshold 0.6
--min-size 40
--upsample 1
--nms 0.3
--source 0|/path/to/video.mp4
--db data/embeddings/known_faces.pkl
--save-vis runs/vis.jpg
YAML (optional): configs/default.yaml
detector: mtcnn
threshold: 0.6
min_size: 40
upsample: 1
nms: 0.3
encoder: dlib_resnet
matcher: cosine
Plug in your machine + dataset results here for transparency.
Detector | FPS (CPU) | FPS (GPU) | Precision | Recall |
---|---|---|---|---|
OpenCV Haar | Β | Β | Β | Β |
MTCNN | Β | Β | Β | Β |
Dlib HOG | Β | Β | Β | Β |
Dlib CNN | Β | Β | Β | Β |
face_recognition | Β | Β | Β | Β |
--upsample
& detector choice.PRs are welcome! Please:
pytest -q
MIT β do your thing, just keep the notice.
If this repo helped your research/product, consider citing:
@software{amitesh_face_recognition_pipeline,
author = {Maurya, Amitesh},
title = {Modular Face Recognition Pipeline with Gradio UI},
year = {2025},
url = {https://github.com/amitesh-maurya/face-recognition-pipeline}
}
face_recognition
, MTCNN authors & maintainers β absolute legends.Got feature ideas? Open an issue. Want a quick tweak for your setup? PRs welcome.