# meryemsakin/helmet-detection-yolov8 architecture

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

- Interactive diagram: https://gitdiagram.com/meryemsakin/helmet-detection-yolov8
- Repository: https://github.com/meryemsakin/helmet-detection-yolov8

## Overview

##### Main Components
- Input Handler: This component is responsible for collecting the input data. The project accepts a folder path (containing images or videos) as input – this can be represented as an "Input Source" node.
- Pre-processing Module: Within main.py and possibly in the helper functions (found in utils/helperFunctions.py), input images/frames are loaded and resized using OpenCV.
- Detection Engine: The core detection part leverages the YOLOv8 models stored in the “models” directory. This component encapsulates the process of loading the pre-trained YOLO models (such as helmetV5_1.pt and the others) and running inference on the pre-processed frames.
- Output Generator: This module handles result logging by storing annotated images in the “Result” directory structure and saving detection data as CSV files (e.g., in Result/floor_1).
- Evaluation Module (Optional): Based on the README details, there is an evaluation phase where confusion matrices, accuracy, and loss metrics are generated and plotted.

##### Architectural Patterns and Key Design Principles
- Modular Design: With separations such as a dedicated models folder, utility functions, and a main script, each component (e.g., data ingestion, processing, inference, and output) is modular.
- Reusability and Extensibility: The clear separation of concerns (and use of an external YOLO model, as well as packages like Supervision) implies that the system can be extended (for example, to work with live camera feeds or to incorporate additional safety equipment detection).

1. Input: User provides folder path → Input Handler.
2. Pre-processing: Images/videos are loaded and resized (using OpenCV/helpers).
3. Detection: Data passed into the YOLOv8 engine (models loaded from the “models” folder).
4. Visualization: Detected helmets are highlighted; annotations are applied (via Supervision & OpenCV).
5. Output: Annotated images and detection CSV are saved into the “Result” folder.
6. (Optional Evaluation): Generation of performance metrics and graphs.

Happy Diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Data Processing Pipeline"
        A["Input Handler (Folder of Images/Videos)"]:::input
        B["Pre-processing (Resize, Normalize)"]:::processing
        C["YOLOv8 Detection Engine"]:::detection
    end

    subgraph "Output Generation"
        D["Visualization & Annotation"]:::visual
        E["Output Generator (CSV & Annotated Images)"]:::output
        F["Evaluation Module (Metrics,ConfusionMatrix)"]:::evaluation
    end

    A -->|"sendsImages/Videos"| B
    B -->|"pre-processedFrames"| C
    C -->|"detectionResults"| D
    C -->|"detectionResults"| E
    E -->|"outputsResults"| F

    click A "https://github.com/meryemsakin/helmet-detection-yolov8/blob/main/main.py"
    click B "https://github.com/meryemsakin/helmet-detection-yolov8/blob/main/utils/helperFunctions.py"
    click C "https://github.com/meryemsakin/helmet-detection-yolov8/tree/main/models"
    click D "https://github.com/meryemsakin/helmet-detection-yolov8/blob/main/main.py"
    click E "https://github.com/meryemsakin/helmet-detection-yolov8/tree/main/Result"
    click F "https://github.com/meryemsakin/helmet-detection-yolov8/blob/main/helmet-detection-yolov8.ipynb"

    classDef input fill:#f9f,stroke:#333,stroke-width:2px;
    classDef processing fill:#ccf,stroke:#333,stroke-width:2px;
    classDef detection fill:#fc3,stroke:#333,stroke-width:2px;
    classDef visual fill:#cfc,stroke:#333,stroke-width:2px;
    classDef output fill:#cff,stroke:#333,stroke-width:2px;
    classDef evaluation fill:#fcc,stroke:#333,stroke-width:2px;
```
