# moeez002/helmet-seatbelt-detection architecture

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

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

## Overview

This is a Streamlit image-based road-safety detector. A user starts the app, chooses helmet or seatbelt detection, uploads an image, and requests results; the app selects the matching YOLO checkpoint, runs prediction, and displays an annotated image. The sampled source is a single file, so the UI, inference, and rendering stages share its path. The README also describes model training and validation, but these are not part of the deployed app workflow.

Main entry points: [`app.py`](https://github.com/moeez002/helmet-seatbelt-detection/blob/main/app.py) (Model loading), [`models/helmet_model.pt`](https://github.com/moeez002/helmet-seatbelt-detection/blob/main/models/helmet_model.pt) (Helmet checkpoint), [`models/seatbelt_model.pt`](https://github.com/moeez002/helmet-seatbelt-detection/blob/main/models/seatbelt_model.pt) (Seatbelt checkpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["User interaction"]
  node_app_ui["Streamlit UI<br/>[app.py]"]
  node_image_input["Image and choice<br/>[app.py]"]
end

subgraph group_detection["Detection workflow"]
  node_model_load["Model loading<br/>[app.py]"]
  node_model_select["Model selection<br/>[app.py]"]
  node_prediction["YOLO prediction<br/>[app.py]"]
  node_render["Result rendering<br/>[app.py]"]
end

subgraph group_weights["Model weights"]
  node_helmet_weights["Helmet checkpoint<br/>[helmet_model.pt]"]
  node_seatbelt_weights["Seatbelt checkpoint<br/>[seatbelt_model.pt]"]
end

node_user(("User"))

node_user -->|"starts and navigates"| node_app_ui
node_user -->|"selects and uploads"| node_image_input
node_app_ui -->|"loads models"| node_model_load
node_model_load -->|"loads"| node_helmet_weights
node_model_load -->|"loads"| node_seatbelt_weights
node_image_input -->|"provides image and choice"| node_model_select
node_model_select -->|"selects model"| node_prediction
node_prediction -->|"returns detections"| node_render
node_render -->|"displays annotated image"| node_user

click node_app_ui "https://github.com/moeez002/helmet-seatbelt-detection/blob/main/app.py"
click node_image_input "https://github.com/moeez002/helmet-seatbelt-detection/blob/main/app.py"
click node_model_load "https://github.com/moeez002/helmet-seatbelt-detection/blob/main/app.py"
click node_model_select "https://github.com/moeez002/helmet-seatbelt-detection/blob/main/app.py"
click node_prediction "https://github.com/moeez002/helmet-seatbelt-detection/blob/main/app.py"
click node_render "https://github.com/moeez002/helmet-seatbelt-detection/blob/main/app.py"
click node_helmet_weights "https://github.com/moeez002/helmet-seatbelt-detection/blob/main/models/helmet_model.pt"
click node_seatbelt_weights "https://github.com/moeez002/helmet-seatbelt-detection/blob/main/models/seatbelt_model.pt"

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_app_ui,node_image_input,node_user toneBlue
class node_model_load,node_model_select,node_prediction,node_render toneAmber
class node_helmet_weights,node_seatbelt_weights toneMint
```

## Components

### User interaction

- [Streamlit UI](https://github.com/moeez002/helmet-seatbelt-detection/blob/main/app.py): `app.py`
- [Image and choice](https://github.com/moeez002/helmet-seatbelt-detection/blob/main/app.py): `app.py`

### Detection workflow

- [Model loading](https://github.com/moeez002/helmet-seatbelt-detection/blob/main/app.py): `app.py`
- [Model selection](https://github.com/moeez002/helmet-seatbelt-detection/blob/main/app.py): `app.py`
- [YOLO prediction](https://github.com/moeez002/helmet-seatbelt-detection/blob/main/app.py): `app.py`
- [Result rendering](https://github.com/moeez002/helmet-seatbelt-detection/blob/main/app.py): `app.py`

### Model weights

- [Helmet checkpoint](https://github.com/moeez002/helmet-seatbelt-detection/blob/main/models/helmet_model.pt): `models/helmet_model.pt`
- [Seatbelt checkpoint](https://github.com/moeez002/helmet-seatbelt-detection/blob/main/models/seatbelt_model.pt): `models/seatbelt_model.pt`

### Other components

- **User**

## Connections

- User → Streamlit UI: starts and navigates
- User → Image and choice: selects and uploads
- Streamlit UI → Model loading: loads models
- Model loading → Helmet checkpoint: loads
- Model loading → Seatbelt checkpoint: loads
- Image and choice → Model selection: provides image and choice
- Model selection → YOLO prediction: selects model
- YOLO prediction → Result rendering: returns detections
- Result rendering → User: displays annotated image
