# nishantrajora/traffic-violation-detection-deep-learning architecture

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

- Interactive diagram: https://gitdiagram.com/nishantrajora/traffic-violation-detection-deep-learning
- Repository: https://github.com/nishantrajora/traffic-violation-detection-deep-learning

## Overview

This repository is a helmet-safety computer-vision project with a FastAPI dashboard for image/video detection, model selection, and visualized safe/violation results. Its documented workflow prepares VOC annotations as YOLO data, trains a detector, evaluates it, then serves detections through the dashboard. The graph also shows the separate model-comparison utility and stored checkpoints. The README documents notebook capabilities and workflow; implementation details for those notebooks and portions of the dashboard are not shown in the excerpts.

Main entry points: [`app.py`](https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/app.py) (Detection dashboard), [`train_model.ipynb`](https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/train_model.ipynb) (Model training), [`saved_models/best.pt`](https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/saved_models/best.pt) (Custom checkpoint), [`compre.py`](https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/compre.py) (Checkpoint comparison)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Dataset preparation"]
  node_voc[("VOC source data")]
  node_split["Dataset splitting<br/>[split_data.ipynb]"]
  node_yolo_data[("YOLO dataset")]
end

subgraph group_model["Model development"]
  node_training["Model training<br/>[train_model.ipynb]"]
  node_custom_weight[("Custom checkpoint<br/>[best.pt]")]
  node_pretrained_weight[("Alternate checkpoint")]
  node_train_artifacts[("Training artifacts")]
end

subgraph group_serve["Detection dashboard"]
  node_app["Detection dashboard<br/>[app.py]"]
  node_inference["Helmet detection<br/>[app.py]"]
  node_classification["Safety classification<br/>[app.py]"]
  node_overlay["Visual results and alerts<br/>[app.py]"]
  node_model_switch["Model selection<br/>[app.py]"]
  node_sample_gallery["Sample image gallery<br/>[app.py]"]
end

subgraph group_analysis["Evaluation"]
  node_evaluation["Model evaluation<br/>[test_model.ipynb]"]
  node_comparison["Checkpoint comparison<br/>[compre.py]"]
  node_validation_artifacts[("Validation artifacts")]
end

node_operator(("User / video source"))

node_voc -->|"converts and splits"| node_split
node_split -->|"produces YOLO data"| node_yolo_data
node_yolo_data -->|"trains on"| node_training
node_training -->|"saves checkpoint"| node_custom_weight
node_training -->|"records results"| node_train_artifacts
node_operator -->|"submits media"| node_app
node_app -->|"runs detection"| node_inference
node_inference -->|"classifies detections"| node_classification
node_classification -->|"annotates results"| node_overlay
node_app -->|"selects model"| node_model_switch
node_model_switch -->|"loads checkpoint"| node_custom_weight
node_model_switch -->|"loads checkpoint"| node_pretrained_weight
node_app -->|"serves samples"| node_sample_gallery
node_yolo_data -->|"evaluates split"| node_evaluation
node_evaluation -->|"records evaluation"| node_validation_artifacts
node_custom_weight -->|"compares model"| node_comparison
node_pretrained_weight -->|"compares model"| node_comparison
node_yolo_data -->|"reads test labels"| node_comparison

click node_split "https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/split_data.ipynb"
click node_training "https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/train_model.ipynb"
click node_custom_weight "https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/saved_models/best.pt"
click node_pretrained_weight "https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/saved_models/helmet_detection_model.pt"
click node_train_artifacts "https://github.com/nishantrajora/traffic-violation-detection-deep-learning/tree/main/runs/detect/train"
click node_app "https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/app.py"
click node_inference "https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/app.py"
click node_classification "https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/app.py"
click node_overlay "https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/app.py"
click node_model_switch "https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/app.py"
click node_sample_gallery "https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/app.py"
click node_evaluation "https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/test_model.ipynb"
click node_comparison "https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/compre.py"
click node_validation_artifacts "https://github.com/nishantrajora/traffic-violation-detection-deep-learning/tree/main/runs/detect/val"

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_voc,node_split,node_yolo_data,node_operator toneBlue
class node_training,node_custom_weight,node_pretrained_weight,node_train_artifacts toneAmber
class node_app,node_inference,node_classification,node_overlay,node_model_switch,node_sample_gallery toneMint
class node_evaluation,node_comparison,node_validation_artifacts toneRose
```

## Components

### Dataset preparation

- **VOC source data**
- [Dataset splitting](https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/split_data.ipynb): `split_data.ipynb`
- **YOLO dataset**

### Model development

- [Model training](https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/train_model.ipynb): `train_model.ipynb`
- [Custom checkpoint](https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/saved_models/best.pt): `saved_models/best.pt`
- [Alternate checkpoint](https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/saved_models/helmet_detection_model.pt): `saved_models/helmet_detection_model.pt`
- [Training artifacts](https://github.com/nishantrajora/traffic-violation-detection-deep-learning/tree/main/runs/detect/train): `runs/detect/train`

### Detection dashboard

- [Detection dashboard](https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/app.py): `app.py`
- [Helmet detection](https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/app.py): `app.py`
- [Safety classification](https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/app.py): `app.py`
- [Visual results and alerts](https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/app.py): `app.py`
- [Model selection](https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/app.py): `app.py`
- [Sample image gallery](https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/app.py): `app.py`

### Evaluation

- [Model evaluation](https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/test_model.ipynb): `test_model.ipynb`
- [Checkpoint comparison](https://github.com/nishantrajora/traffic-violation-detection-deep-learning/blob/main/compre.py): `compre.py`
- [Validation artifacts](https://github.com/nishantrajora/traffic-violation-detection-deep-learning/tree/main/runs/detect/val): `runs/detect/val`

### Other components

- **User / video source**

## Connections

- VOC source data → Dataset splitting: converts and splits (evidence: `README.md`)
- Dataset splitting → YOLO dataset: produces YOLO data (evidence: `README.md`)
- YOLO dataset → Model training: trains on (evidence: `README.md`)
- Model training → Custom checkpoint: saves checkpoint (evidence: `README.md`)
- Model training → Training artifacts: records results (evidence: `README.md`)
- User / video source → Detection dashboard: submits media (evidence: `README.md`)
- Detection dashboard → Helmet detection: runs detection (evidence: `app.py`)
- Helmet detection → Safety classification: classifies detections (evidence: `app.py`)
- Safety classification → Visual results and alerts: annotates results (evidence: `app.py`)
- Detection dashboard → Model selection: selects model (evidence: `app.py`)
- Model selection → Custom checkpoint: loads checkpoint (evidence: `app.py`)
- Model selection → Alternate checkpoint: loads checkpoint (evidence: `README.md`)
- Detection dashboard → Sample image gallery: serves samples (evidence: `app.py`)
- YOLO dataset → Model evaluation: evaluates split (evidence: `README.md`)
- Model evaluation → Validation artifacts: records evaluation (evidence: `README.md`)
- Custom checkpoint → Checkpoint comparison: compares model (evidence: `compre.py`)
- Alternate checkpoint → Checkpoint comparison: compares model (evidence: `compre.py`)
- YOLO dataset → Checkpoint comparison: reads test labels (evidence: `compre.py`)
