# abs6187/helmet-detection architecture

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

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

## Overview

This repository’s runnable product is a Gradio image interface for helmet detection. A user uploads an image or selects an example; the app runs a loaded YOLO model, draws detections, and returns an annotated image. The README also describes broader video, CSV, and evaluation workflows, but the sampled runtime source does not show those paths, so they are not presented as implemented runtime components.

Main entry points: [`app.py`](https://github.com/abs6187/helmet-detection/blob/main/app.py) (Gradio interface), [`images`](https://github.com/abs6187/helmet-detection/tree/main/images) (Example images), [`yolov11nbest.pt`](https://github.com/abs6187/helmet-detection/blob/main/yolov11nbest.pt) (YOLOv11 weights)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Image interface"]
  node_gradio["Gradio interface<br/>[app.py]"]
  node_examples["Example image loader<br/>[app.py]"]
  node_image_files["Example images"]
end

subgraph group_inference["Detection pipeline"]
  node_predict["Prediction function<br/>[app.py]"]
  node_yolo["YOLO model<br/>[app.py]"]
  node_weights["YOLOv11 weights<br/>[yolov11nbest.pt]"]
  node_annotate["Detection plotting<br/>[app.py]"]
  node_result["Annotated image<br/>[app.py]"]
end

node_user(("Image user"))

node_user -->|"uploads image"| node_gradio
node_gradio -->|"invokes"| node_predict
node_examples -->|"lists files"| node_image_files
node_gradio -->|"loads examples"| node_examples
node_yolo -->|"loads weights"| node_weights
node_predict -->|"runs inference"| node_yolo
node_predict -->|"plots detections"| node_annotate
node_annotate -->|"converts to image"| node_result
node_gradio -->|"returns result"| node_user

click node_gradio "https://github.com/abs6187/helmet-detection/blob/main/app.py"
click node_examples "https://github.com/abs6187/helmet-detection/blob/main/app.py"
click node_image_files "https://github.com/abs6187/helmet-detection/tree/main/images"
click node_predict "https://github.com/abs6187/helmet-detection/blob/main/app.py"
click node_yolo "https://github.com/abs6187/helmet-detection/blob/main/app.py"
click node_weights "https://github.com/abs6187/helmet-detection/blob/main/yolov11nbest.pt"
click node_annotate "https://github.com/abs6187/helmet-detection/blob/main/app.py"
click node_result "https://github.com/abs6187/helmet-detection/blob/main/app.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_gradio,node_examples,node_image_files,node_user toneBlue
class node_predict,node_yolo,node_weights,node_annotate,node_result toneAmber
```

## Components

### Image interface

- [Gradio interface](https://github.com/abs6187/helmet-detection/blob/main/app.py): `app.py`
- [Example image loader](https://github.com/abs6187/helmet-detection/blob/main/app.py): `app.py`
- [Example images](https://github.com/abs6187/helmet-detection/tree/main/images): `images`

### Detection pipeline

- [Prediction function](https://github.com/abs6187/helmet-detection/blob/main/app.py): `app.py`
- [YOLO model](https://github.com/abs6187/helmet-detection/blob/main/app.py): `app.py`
- [YOLOv11 weights](https://github.com/abs6187/helmet-detection/blob/main/yolov11nbest.pt): `yolov11nbest.pt`
- [Detection plotting](https://github.com/abs6187/helmet-detection/blob/main/app.py): `app.py`
- [Annotated image](https://github.com/abs6187/helmet-detection/blob/main/app.py): `app.py`

### Other components

- **Image user**

## Connections

- Image user → Gradio interface: uploads image (evidence: `app.py`)
- Gradio interface → Prediction function: invokes (evidence: `app.py`)
- Example image loader → Example images: lists files (evidence: `app.py`)
- Gradio interface → Example image loader: loads examples (evidence: `app.py`)
- YOLO model → YOLOv11 weights: loads weights (evidence: `app.py`)
- Prediction function → YOLO model: runs inference (evidence: `app.py`)
- Prediction function → Detection plotting: plots detections (evidence: `app.py`)
- Detection plotting → Annotated image: converts to image (evidence: `app.py`)
- Gradio interface → Image user: returns result (evidence: `app.py`)
