- Reza Dadbin — GitHub: https://github.com/RezaDadbin
- Sina Lotfi — GitHub: https://github.com/cinaLotfi
Face Recognition GUI is a desktop application written in Python that performs real-time face recognition using your computer’s webcam. It allows you to capture and label faces (assign names to them) and later recognize those faces live in front of the camera — all through a simple, graphical interface built with Tkinter.
This educational project performs enrollment and recognition locally, without a cloud recognition service. Initial dependency installation and the first pretrained FaceNet initialization may require internet access to download weights; recognition can run offline after those weights are cached.
The system uses two deep learning models from the facenet-pytorch library:
- MTCNN for detecting faces in each video frame.
- InceptionResnetV1 (FaceNet) for converting faces into 512-dimensional numerical embeddings.
- Real-time webcam processing with OpenCV
- Face detection with MTCNN and embedding extraction with FaceNet
- Local enrollment and recognition without cloud APIs
- A Tkinter GUI for labeling faces and running prediction mode
The pipeline has three main stages: Face Detection → Face Embedding → Face Recognition.
Each webcam frame is processed with MTCNN, which returns bounding boxes around one or more faces in the image.
Each detected face is cropped and resized to 160×160, then fed into FaceNet, producing a 512-dimensional embedding (a numeric vector that represents the face). The embedding distances are used to compare enrolled faces with incoming images. Recognition quality depends on image conditions, enrollment data, and the selected threshold.
When you label faces, each image is saved locally under:
face_data/<person_name>/
The app computes embeddings for all stored images and keeps them in memory. During recognition, a new face’s embedding is compared to all stored embeddings using Euclidean distance. The smallest distance is taken as the match; if it’s smaller than a configurable threshold (default 1.0), the system labels that face as known; otherwise it shows “Unknown.”
git clone https://github.com/RezaDadbin/Real-time-Face-recognition.git
cd Real-time-Face-recognition
python -m venv .venv
source .venv/bin/activate # macOS/Linux
# or
.venv\Scripts\activate # Windows
pip install -r requirements.txt
python -m src.face_rec_gui.app- In the main window, click “Labeling UI.”
- Enter a person’s name.
- The webcam opens:
- Press
sto save the current frame toface_data/<name>/. - Press
qto quit labeling mode.
- Press
- After quitting, embeddings are computed for all saved images.
- From the main window, click “Prediction UI.”
- The webcam starts and detects faces live.
- Each face is embedded and compared to known ones.
- If the smallest distance is below the threshold, the name appears on the bounding box; otherwise it shows Unknown.
- Press
qto exit.
device: "cpu" # or "cuda" for GPU
database_path: "face_data"
recognition_threshold: 1.0 # smaller = stricter; larger = more lenient
camera_index: 0 # change if you have multiple webcams| Component | Purpose |
|---|---|
| Tkinter | Graphical user interface |
| OpenCV | Webcam frames & drawing |
| MTCNN | Face detection |
| FaceNet (InceptionResnetV1) | 512-D face embeddings |
| NumPy | Vector math & distances |
| PyTorch | Deep model execution |
| YAML | Config management |
Recognition decision: for a new embedding e_new, compute distances d_i = ||e_new - e_stored,i||_2. Let d_min = min_i d_i. If d_min < threshold, assign the corresponding label; else Unknown.
With the dependencies installed, run the existing tests from the repository root:
python -m pytest -qCI uses the same invocation so the repository root is available for the src.face_rec_gui import.
Enrolled images are stored locally in face_data/ and processed locally by the application. Pretrained FaceNet weights may be downloaded on first initialization and cached by facenet-pytorch. This project does not establish a validated biometric-security or privacy guarantee.