# yusrialsanaani/face_mask_detection_using_yolo_and_mtcnn architecture

> Architecture diagram of the GitHub repository yusrialsanaani/face_mask_detection_using_yolo_and_mtcnn, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yusrialsanaani/face_mask_detection_using_yolo_and_mtcnn
- Repository: https://github.com/yusrialsanaani/face_mask_detection_using_yolo_and_mtcnn

## Overview

##### Project Type and Overall Purpose
- The project is a deep learning application for automated face mask detection.
- It is structured around two parallel detection pipelines: a two-stage method (MTCNN + CNN/VGG19) and a one-stage YOLOv5 method.
- The README provides detailed metrics, training curves, dataset information, and a comparison of results between the pipelines.

##### Main Components
- Input Data: Represent the source datasets (Kaggle face mask images for each pipeline). Highlight the preprocessing steps (e.g., data augmentation, normalization if applicable).
- Pipeline 1 Components:
- MTCNN Detector: This module is responsible for locating face regions.
- CNN Classifier: A basic convolutional model for determining mask presence. Also note the enhanced version using transfer learning (VGG19) that improves performance.
- Post-Processing: Evaluation outputs (accuracy, loss curves, ROC curves) can be optionally depicted to show the model’s performance monitoring.
- Pipeline 2 Components (YOLOv5):
- YOLOv5 Network: A one-stage detector that processes images to directly perform object detection and classification.
- Common Components:
- Training & Validation Processes: Include data splits, training loops, and evaluation metrics.
- Performance Comparison: Optionally show an area where the outputs or evaluations from both pipelines converge to support the claim regarding YOLO’s speed and accuracy.

- Image Dataset input → Preprocessing module → Branching into two pipelines.
- In Pipeline 1: Images go to the MTCNN detector; detected face regions pass to CNN/VGG19 classifier; results are combined for the final mask detection decision.
- In Pipeline 2: YOLOv5 processes the entire image and outputs object detection and classification in one pass.
- Decision point where the system might choose between pipelines or simply compare results post-processing.
- Sharing of common utilities or evaluation frameworks (for plotting training curves and performance metrics) if applicable.

##### Architectural Patterns and Design Principles
- Modularity by representing each pipeline as a separate module/block.
- Two-stage design in Pipeline 1 (sequential processing) and the one-stage detection in Pipeline 2.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Dataset (Kaggle Face Mask Images)"]:::external
    B["Preprocessing / Data Augmentation"]:::process
    C["Training & Validation"]:::process

    A -->|"DataInput"| B
    B -->|"PreparesData"| C

    subgraph "Two-Stage Pipeline (MTCNN + CNN/VGG19)"
        D["MTCNN Face Detector"]:::blue
        E["CNN Classifier (with Transfer Learning – VGG19)"]:::blue
        C -->|"DetectFaces"| D
        D -->|"ClassifyFace"| E
    end

    subgraph "One-Stage Pipeline (YOLOv5)"
        F["YOLOv5 Detection Pipeline"]:::green
        C -->|"DirectDetection"| F
    end

    G["Evaluation & Metrics (Model Performance)"]:::evaluation
    E -->|"EvaluationResults"| G
    F -->|"EvaluationResults"| G

    click D "https://github.com/yusrialsanaani/face_mask_detection_using_yolo_and_mtcnn/blob/main/Face_Mask_Detection.ipynb"
    click E "https://github.com/yusrialsanaani/face_mask_detection_using_yolo_and_mtcnn/blob/main/Face_Mask_Detection.ipynb"
    click F "https://github.com/yusrialsanaani/face_mask_detection_using_yolo_and_mtcnn/blob/main/Face_Mask_Detection_YOLO5.ipynb"
    click G "https://github.com/yusrialsanaani/face_mask_detection_using_yolo_and_mtcnn/blob/main/README.md"

    classDef external fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef process fill:#ffe6cc,stroke:#333,stroke-width:2px;
    classDef blue fill:#99ccff,stroke:#333,stroke-width:2px;
    classDef green fill:#99ff99,stroke:#333,stroke-width:2px;
    classDef evaluation fill:#dddddd,stroke:#333,stroke-width:2px;
```
