# thehamzza/facial_recognition_based_attendance_system architecture

> Architecture diagram of the GitHub repository thehamzza/facial_recognition_based_attendance_system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thehamzza/facial_recognition_based_attendance_system
- Repository: https://github.com/thehamzza/facial_recognition_based_attendance_system

## Overview

This is a small, script-based facial-recognition attendance application. Its documented workflow captures labeled face samples, trains an LBPH recognizer, then recognizes people from a live camera session and writes present/absent results to an Excel workbook. The README also mentions facial-expression detection, but the sampled runtime scripts show face detection and recognition rather than expression analysis. The graph reflects only relationships visible in the supplied source excerpts or README; hard-coded paths and some stored artifacts are included without assuming additional runtime behavior.

Main entry points: [`03_face_recognition_with_attendance.py`](https://github.com/thehamzza/facial_recognition_based_attendance_system/blob/main/03_face_recognition_with_attendance.py) (Recognize and mark), [`01_face_dataset.py`](https://github.com/thehamzza/facial_recognition_based_attendance_system/blob/main/01_face_dataset.py) (Capture samples), [`02_face_training.py`](https://github.com/thehamzza/facial_recognition_based_attendance_system/blob/main/02_face_training.py) (Train recognizer), [`Cascades/haarcascade_frontalface_default.xml`](https://github.com/thehamzza/facial_recognition_based_attendance_system/blob/main/Cascades/haarcascade_frontalface_default.xml) (Face cascade)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Face capture"]
  node_capture_script["Capture samples<br/>[01_face_dataset.py]"]
end

subgraph group_training["Model training"]
  node_training_script["Train recognizer"]
end

subgraph group_attendance["Attendance recognition"]
  node_attendance_script["Recognize and mark"]
  node_excel_writer["Excel writer"]
end

subgraph group_artifacts["Stored artifacts"]
  node_face_cascade["Face cascade"]
  node_dataset["Face images"]
  node_trainer_model["LBPH model<br/>[trainer.yml]"]
  node_attendance_files["Attendance workbooks"]
end

node_operator(("Operator"))
node_camera["Camera"]

node_operator -->|"enters ID"| node_capture_script
node_camera -->|"supplies frames"| node_capture_script
node_capture_script -->|"detects faces"| node_face_cascade
node_capture_script -->|"saves samples"| node_dataset
node_dataset -->|"provides images"| node_training_script
node_training_script -->|"detects faces"| node_face_cascade
node_training_script -->|"writes model"| node_trainer_model
node_camera -->|"supplies frames"| node_attendance_script
node_attendance_script -->|"detects faces"| node_face_cascade
node_attendance_script -->|"loads and predicts"| node_trainer_model
node_attendance_script -->|"provides attendance"| node_excel_writer
node_excel_writer -->|"writes workbook"| node_attendance_files

click node_capture_script "https://github.com/thehamzza/facial_recognition_based_attendance_system/blob/main/01_face_dataset.py"
click node_face_cascade "https://github.com/thehamzza/facial_recognition_based_attendance_system/blob/main/Cascades/haarcascade_frontalface_default.xml"
click node_dataset "https://github.com/thehamzza/facial_recognition_based_attendance_system/tree/main/dataset"
click node_training_script "https://github.com/thehamzza/facial_recognition_based_attendance_system/blob/main/02_face_training.py"
click node_trainer_model "https://github.com/thehamzza/facial_recognition_based_attendance_system/blob/main/trainer/trainer.yml"
click node_attendance_script "https://github.com/thehamzza/facial_recognition_based_attendance_system/blob/main/03_face_recognition_with_attendance.py"
click node_excel_writer "https://github.com/thehamzza/facial_recognition_based_attendance_system/blob/main/03_face_recognition_with_attendance.py"
click node_attendance_files "https://github.com/thehamzza/facial_recognition_based_attendance_system/tree/main/Attendance"

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 toneBlue
class node_training_script toneAmber
class node_attendance_script,node_excel_writer toneMint
class node_face_cascade,node_dataset,node_trainer_model,node_attendance_files toneRose
class node_operator,node_camera toneIndigo
```

## Components

### Face capture

- [Capture samples](https://github.com/thehamzza/facial_recognition_based_attendance_system/blob/main/01_face_dataset.py): `01_face_dataset.py`

### Model training

- [Train recognizer](https://github.com/thehamzza/facial_recognition_based_attendance_system/blob/main/02_face_training.py): `02_face_training.py`

### Attendance recognition

- [Recognize and mark](https://github.com/thehamzza/facial_recognition_based_attendance_system/blob/main/03_face_recognition_with_attendance.py): `03_face_recognition_with_attendance.py`
- [Excel writer](https://github.com/thehamzza/facial_recognition_based_attendance_system/blob/main/03_face_recognition_with_attendance.py): `03_face_recognition_with_attendance.py`

### Stored artifacts

- [Face cascade](https://github.com/thehamzza/facial_recognition_based_attendance_system/blob/main/Cascades/haarcascade_frontalface_default.xml): `Cascades/haarcascade_frontalface_default.xml`
- [Face images](https://github.com/thehamzza/facial_recognition_based_attendance_system/tree/main/dataset): `dataset`
- [LBPH model](https://github.com/thehamzza/facial_recognition_based_attendance_system/blob/main/trainer/trainer.yml): `trainer/trainer.yml`
- [Attendance workbooks](https://github.com/thehamzza/facial_recognition_based_attendance_system/tree/main/Attendance): `Attendance`

### Other components

- **Operator**
- **Camera**

## Connections

- Operator → Capture samples: enters ID (evidence: `01_face_dataset.py`)
- Camera → Capture samples: supplies frames (evidence: `01_face_dataset.py`)
- Capture samples → Face cascade: detects faces (evidence: `01_face_dataset.py`)
- Capture samples → Face images: saves samples (evidence: `01_face_dataset.py`)
- Face images → Train recognizer: provides images (evidence: `02_face_training.py`)
- Train recognizer → Face cascade: detects faces (evidence: `02_face_training.py`)
- Train recognizer → LBPH model: writes model (evidence: `02_face_training.py`)
- Camera → Recognize and mark: supplies frames (evidence: `03_face_recognition_with_attendance.py`)
- Recognize and mark → Face cascade: detects faces (evidence: `03_face_recognition_with_attendance.py`)
- Recognize and mark → LBPH model: loads and predicts (evidence: `03_face_recognition_with_attendance.py`)
- Recognize and mark → Excel writer: provides attendance (evidence: `03_face_recognition_with_attendance.py`)
- Excel writer → Attendance workbooks: writes workbook (evidence: `03_face_recognition_with_attendance.py`)
