# sak-cmd-web/face_recognition_system architecture

> Architecture diagram of the GitHub repository sak-cmd-web/face_recognition_system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sak-cmd-web/face_recognition_system
- Repository: https://github.com/sak-cmd-web/face_recognition_system

## Overview

This is a webcam-based face recognition project with two separate recognition approaches: OpenCV LBPH and an InceptionResNetV2 classifier. The main workflow captures face images, trains a recognizer from labeled image folders, then detects and classifies faces from a live camera feed; LBPH also has a validation script. The README documents both detectors and both training/inference paths. Some referenced datasets and trained artifacts are absent from the tree, so their connections are shown as external data rather than repository nodes.

Main entry points: [`ml-lbph/webcam.py`](https://github.com/sak-cmd-web/face_recognition_system/blob/main/ml-lbph/webcam.py) (LBPH webcam recognition), [`dl-resnetv2/train.py`](https://github.com/sak-cmd-web/face_recognition_system/blob/main/dl-resnetv2/train.py) (Train InceptionResNetV2), [`dl-resnetv2/webcam.py`](https://github.com/sak-cmd-web/face_recognition_system/blob/main/dl-resnetv2/webcam.py) (DL webcam recognition), [`helpers/dnn_detector.py`](https://github.com/sak-cmd-web/face_recognition_system/blob/main/helpers/dnn_detector.py) (DNN SSD detector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Image capture"]
  node_capture_script["Capture faces<br/>[capture.py]"]
  node_captured_images["Captured images"]
end

subgraph group_lbph["LBPH recognition"]
  node_lbph_train["Train LBPH<br/>[train.py]"]
  node_lbph_model["LBPH model and labels"]
  node_lbph_validate["Validate LBPH<br/>[val.py]"]
  node_lbph_webcam["LBPH webcam recognition<br/>[webcam.py]"]
end

subgraph group_deep["Deep learning"]
  node_dl_train["Train InceptionResNetV2<br/>[train.py]"]
  node_dl_utils["Class-name mapping<br/>[utils.py]"]
  node_dl_model["DL model and labels"]
  node_dl_webcam["DL webcam recognition<br/>[webcam.py]"]
end

subgraph group_detection["Face detection"]
  node_haar["Haar detector<br/>[haar_detector.py]"]
  node_dnn["DNN SSD detector<br/>[dnn_detector.py]"]
end

node_user(("User"))
node_camera(("Webcam"))
node_dataset["Labeled images"]
node_dnn_config["SSD model files<br/>[deploy.prototxt]"]
node_dnn_weights["SSD weights"]

node_user -->|"starts capture"| node_capture_script
node_capture_script -->|"reads frames"| node_camera
node_capture_script -->|"writes crops"| node_captured_images
node_user -->|"starts training"| node_lbph_train
node_dataset -->|"provides training images"| node_lbph_train
node_lbph_train -->|"writes model and labels"| node_lbph_model
node_dataset -->|"provides validation images"| node_lbph_validate
node_lbph_model -->|"loads model and labels"| node_lbph_validate
node_user -->|"starts recognition"| node_lbph_webcam
node_camera -->|"supplies frames"| node_lbph_webcam
node_lbph_webcam -->|"loads model and labels"| node_lbph_model
node_lbph_webcam -->|"detects faces"| node_dnn
node_dnn -->|"loads configuration"| node_dnn_config
node_dnn -->|"loads weights"| node_dnn_weights
node_user -->|"starts training"| node_dl_train
node_dataset -->|"provides training and validation images"| node_dl_train
node_dl_train -->|"saves class mapping"| node_dl_utils
node_dl_train -->|"writes model and labels"| node_dl_model
node_user -->|"starts recognition"| node_dl_webcam
node_camera -->|"supplies frames"| node_dl_webcam
node_dl_webcam -->|"loads model and labels"| node_dl_model
node_dl_webcam -->|"detects faces"| node_dnn

click node_capture_script "https://github.com/sak-cmd-web/face_recognition_system/blob/main/capture.py"
click node_lbph_train "https://github.com/sak-cmd-web/face_recognition_system/blob/main/ml-lbph/train.py"
click node_lbph_validate "https://github.com/sak-cmd-web/face_recognition_system/blob/main/ml-lbph/val.py"
click node_lbph_webcam "https://github.com/sak-cmd-web/face_recognition_system/blob/main/ml-lbph/webcam.py"
click node_dl_train "https://github.com/sak-cmd-web/face_recognition_system/blob/main/dl-resnetv2/train.py"
click node_dl_utils "https://github.com/sak-cmd-web/face_recognition_system/blob/main/dl-resnetv2/utils.py"
click node_dl_webcam "https://github.com/sak-cmd-web/face_recognition_system/blob/main/dl-resnetv2/webcam.py"
click node_haar "https://github.com/sak-cmd-web/face_recognition_system/blob/main/helpers/haar_detector.py"
click node_dnn "https://github.com/sak-cmd-web/face_recognition_system/blob/main/helpers/dnn_detector.py"
click node_dnn_config "https://github.com/sak-cmd-web/face_recognition_system/blob/main/source/deploy.prototxt"
click node_dnn_weights "https://github.com/sak-cmd-web/face_recognition_system/blob/main/source/res10_300x300_ssd_iter_140000.caffemodel"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_capture_script,node_captured_images,node_user toneBlue
class node_lbph_train,node_lbph_model,node_lbph_validate,node_lbph_webcam toneAmber
class node_dl_train,node_dl_utils,node_dl_model,node_dl_webcam toneMint
class node_haar,node_dnn toneRose
class node_camera,node_dataset,node_dnn_config toneIndigo
class node_dnn_weights toneTeal
```

## Components

### Image capture

- [Capture faces](https://github.com/sak-cmd-web/face_recognition_system/blob/main/capture.py): `capture.py`
- **Captured images**

### LBPH recognition

- [Train LBPH](https://github.com/sak-cmd-web/face_recognition_system/blob/main/ml-lbph/train.py): `ml-lbph/train.py`
- **LBPH model and labels**
- [Validate LBPH](https://github.com/sak-cmd-web/face_recognition_system/blob/main/ml-lbph/val.py): `ml-lbph/val.py`
- [LBPH webcam recognition](https://github.com/sak-cmd-web/face_recognition_system/blob/main/ml-lbph/webcam.py): `ml-lbph/webcam.py`

### Deep learning

- [Train InceptionResNetV2](https://github.com/sak-cmd-web/face_recognition_system/blob/main/dl-resnetv2/train.py): `dl-resnetv2/train.py`
- [Class-name mapping](https://github.com/sak-cmd-web/face_recognition_system/blob/main/dl-resnetv2/utils.py): `dl-resnetv2/utils.py`
- **DL model and labels**
- [DL webcam recognition](https://github.com/sak-cmd-web/face_recognition_system/blob/main/dl-resnetv2/webcam.py): `dl-resnetv2/webcam.py`

### Face detection

- [Haar detector](https://github.com/sak-cmd-web/face_recognition_system/blob/main/helpers/haar_detector.py): `helpers/haar_detector.py`
- [DNN SSD detector](https://github.com/sak-cmd-web/face_recognition_system/blob/main/helpers/dnn_detector.py): `helpers/dnn_detector.py`

### Other components

- **User**
- **Webcam**
- **Labeled images**
- [SSD model files](https://github.com/sak-cmd-web/face_recognition_system/blob/main/source/deploy.prototxt): `source/deploy.prototxt`
- [SSD weights](https://github.com/sak-cmd-web/face_recognition_system/blob/main/source/res10_300x300_ssd_iter_140000.caffemodel): `source/res10_300x300_ssd_iter_140000.caffemodel`

## Connections

- User → Capture faces: starts capture
- Capture faces → Webcam: reads frames
- Capture faces → Captured images: writes crops
- User → Train LBPH: starts training
- Labeled images → Train LBPH: provides training images
- Train LBPH → LBPH model and labels: writes model and labels
- Labeled images → Validate LBPH: provides validation images
- LBPH model and labels → Validate LBPH: loads model and labels
- User → LBPH webcam recognition: starts recognition
- Webcam → LBPH webcam recognition: supplies frames
- LBPH webcam recognition → LBPH model and labels: loads model and labels
- LBPH webcam recognition → DNN SSD detector: detects faces
- DNN SSD detector → SSD model files: loads configuration
- DNN SSD detector → SSD weights: loads weights
- User → Train InceptionResNetV2: starts training
- Labeled images → Train InceptionResNetV2: provides training and validation images
- Train InceptionResNetV2 → Class-name mapping: saves class mapping
- Train InceptionResNetV2 → DL model and labels: writes model and labels
- User → DL webcam recognition: starts recognition
- Webcam → DL webcam recognition: supplies frames
- DL webcam recognition → DL model and labels: loads model and labels
- DL webcam recognition → DNN SSD detector: detects faces
