# ajaykumar-847/face-mask-detection-and-recognition architecture

> Architecture diagram of the GitHub repository ajaykumar-847/face-mask-detection-and-recognition, 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/ajaykumar-847/face-mask-detection-and-recognition
- Repository: https://github.com/ajaykumar-847/face-mask-detection-and-recognition

## Overview

This repository trains a face-mask classifier, builds a face-identity encoding file, and runs a webcam application that detects faces, classifies mask use, identifies recognized people without masks, and speaks a warning. Training and identity enrollment are separate preparation workflows; the runtime entry point coordinates live detection and warnings. Edges are limited to relationships shown in the sampled scripts; the README is empty.

Main entry points: [`detect_mask.py`](https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/detect_mask.py) (Start detection), [`train_mask_detector.py`](https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/train_mask_detector.py) (Train classifier), [`facerec_video.py`](https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/facerec_video.py) (Build encodings), [`mask_detector.model`](https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/mask_detector.model) (Mask model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Model training"]
  node_dataset["Mask dataset"]
  node_trainer["Train classifier"]
  node_mask_model["Mask model"]
end

subgraph group_identity["Identity enrollment"]
  node_identity_images["Identity images"]
  node_encoder["Build encodings<br/>[facerec_video.py]"]
  node_encodings["Face encodings"]
end

subgraph group_runtime["Live detection"]
  node_runtime["Start detection<br/>[detect_mask.py]"]
  node_face_assets["Face detector assets"]
  node_face_detection["Detect faces<br/>[detect_mask.py]"]
  node_mask_classification["Classify mask use<br/>[detect_mask.py]"]
  node_identity_lookup["Recognize people<br/>[detect_mask.py]"]
  node_warning["Speak warning<br/>[detect_mask.py]"]
  node_display["Display results<br/>[detect_mask.py]"]
end

node_operator(("Operator"))
node_webcam(("Webcam"))

node_dataset -->|"supplies images"| node_trainer
node_trainer -->|"saves model"| node_mask_model
node_identity_images -->|"provides images"| node_encoder
node_encoder -->|"writes encodings"| node_encodings
node_operator -->|"starts"| node_runtime
node_webcam -->|"streams frames"| node_runtime
node_runtime -->|"loads model"| node_mask_model
node_runtime -->|"loads detector"| node_face_assets
node_runtime -->|"loads identities"| node_encodings
node_runtime -->|"calls"| node_face_detection
node_face_detection -->|"predicts faces"| node_mask_classification
node_runtime -->|"looks up unmasked"| node_identity_lookup
node_runtime -->|"speaks warning"| node_warning
node_runtime -->|"shows frame"| node_display

click node_dataset "https://github.com/ajaykumar-847/face-mask-detection-and-recognition/tree/main/dataset"
click node_trainer "https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/train_mask_detector.py"
click node_mask_model "https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/mask_detector.model"
click node_identity_images "https://github.com/ajaykumar-847/face-mask-detection-and-recognition/tree/main/Images"
click node_encoder "https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/facerec_video.py"
click node_encodings "https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/face_enc"
click node_runtime "https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/detect_mask.py"
click node_face_assets "https://github.com/ajaykumar-847/face-mask-detection-and-recognition/tree/main/face_detector"
click node_face_detection "https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/detect_mask.py"
click node_mask_classification "https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/detect_mask.py"
click node_identity_lookup "https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/detect_mask.py"
click node_warning "https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/detect_mask.py"
click node_display "https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/detect_mask.py"

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_dataset,node_trainer,node_mask_model toneBlue
class node_identity_images,node_encoder,node_encodings toneAmber
class node_runtime,node_face_assets,node_face_detection,node_mask_classification,node_identity_lookup,node_warning,node_display toneMint
class node_operator,node_webcam toneIndigo
```

## Components

### Model training

- [Mask dataset](https://github.com/ajaykumar-847/face-mask-detection-and-recognition/tree/main/dataset): `dataset`
- [Train classifier](https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/train_mask_detector.py): `train_mask_detector.py`
- [Mask model](https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/mask_detector.model): `mask_detector.model`

### Identity enrollment

- [Identity images](https://github.com/ajaykumar-847/face-mask-detection-and-recognition/tree/main/Images): `Images`
- [Build encodings](https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/facerec_video.py): `facerec_video.py`
- [Face encodings](https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/face_enc): `face_enc`

### Live detection

- [Start detection](https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/detect_mask.py): `detect_mask.py`
- [Face detector assets](https://github.com/ajaykumar-847/face-mask-detection-and-recognition/tree/main/face_detector): `face_detector`
- [Detect faces](https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/detect_mask.py): `detect_mask.py`
- [Classify mask use](https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/detect_mask.py): `detect_mask.py`
- [Recognize people](https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/detect_mask.py): `detect_mask.py`
- [Speak warning](https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/detect_mask.py): `detect_mask.py`
- [Display results](https://github.com/ajaykumar-847/face-mask-detection-and-recognition/blob/main/detect_mask.py): `detect_mask.py`

### Other components

- **Operator**
- **Webcam**

## Connections

- Mask dataset → Train classifier: supplies images (evidence: `train_mask_detector.py`)
- Train classifier → Mask model: saves model (evidence: `train_mask_detector.py`)
- Identity images → Build encodings: provides images (evidence: `facerec_video.py`)
- Build encodings → Face encodings: writes encodings (evidence: `facerec_video.py`)
- Operator → Start detection: starts (evidence: `detect_mask.py`)
- Webcam → Start detection: streams frames (evidence: `detect_mask.py`)
- Start detection → Mask model: loads model (evidence: `detect_mask.py`)
- Start detection → Face detector assets: loads detector (evidence: `detect_mask.py`)
- Start detection → Face encodings: loads identities (evidence: `detect_mask.py`)
- Start detection → Detect faces: calls (evidence: `detect_mask.py`)
- Detect faces → Classify mask use: predicts faces (evidence: `detect_mask.py`)
- Start detection → Recognize people: looks up unmasked (evidence: `detect_mask.py`)
- Start detection → Speak warning: speaks warning (evidence: `detect_mask.py`)
- Start detection → Display results: shows frame (evidence: `detect_mask.py`)
