# makebuz/moto-detector architecture

> Architecture diagram of the GitHub repository makebuz/moto-detector, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/makebuz/moto-detector
- Repository: https://github.com/makebuz/moto-detector

## Overview

moto-detector is an academic motorcycle and helmet-detection research project, not a deployed application. Its practical workflow is to audit and prepare image data, obtain human-reviewed annotations, consolidate a four-class dataset, train models from scratch, and inspect predictions and geometric head-to-motorcycle proposals. The README also describes a crop-based helmet classifier and experiment reporting; video, counting, and a statistics assistant are explicitly unfinished. Edges reflect shown calls or README descriptions; unsampled behavior is not inferred.

Main entry points: [`training/train.py`](https://github.com/makebuz/moto-detector/blob/main/training/train.py) (Training and validation), [`training/models.py`](https://github.com/makebuz/moto-detector/blob/main/training/models.py) (Model architectures), [`training/overfit_heads.py`](https://github.com/makebuz/moto-detector/blob/main/training/overfit_heads.py) (Head diagnostics), [`training/review_errors.py`](https://github.com/makebuz/moto-detector/blob/main/training/review_errors.py) (Error review)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_audit["Dataset audit<br/>[audit-dataset.mjs]"]
  node_prepare["Dataset preparation"]
  node_utils["Dataset utilities<br/>[dataset-utils.mjs]"]
  node_verify["Dataset verification"]
end

subgraph group_review["Human review"]
  node_batch["Annotation batches"]
  node_validate["Review validation"]
  node_labels["Label conversion"]
  node_consolidate["Dataset consolidation"]
  node_annotations[("Reviewed annotations")]
end

subgraph group_model["Modeling and evaluation"]
  node_data_loader["Training data<br/>[data.py]"]
  node_architectures["Model architectures<br/>[models.py]"]
  node_trainer["Training and validation<br/>[train.py]"]
  node_metrics["Detection metrics<br/>[metrics.py]"]
  node_memorization["Head diagnostics<br/>[overfit_heads.py]"]
end

subgraph group_analysis["Prediction analysis"]
  node_predict["Prediction<br/>[predict.py]"]
  node_association["Geometric association<br/>[association.py]"]
  node_error_review["Error review<br/>[review_errors.py]"]
  node_relation_eval["Relation evaluation"]
end

node_researcher(("Researcher"))
node_human(("Human annotator"))

node_researcher -->|"audits data"| node_audit
node_researcher -->|"prepares data"| node_prepare
node_prepare -->|"uses utilities"| node_utils
node_researcher -->|"starts review"| node_batch
node_batch -->|"queues images"| node_human
node_human -->|"reviews labels"| node_annotations
node_validate -->|"validates review"| node_annotations
node_consolidate -->|"validates batches"| node_validate
node_consolidate -->|"converts labels"| node_labels
node_researcher -->|"verifies dataset"| node_verify
node_trainer -->|"loads samples"| node_data_loader
node_trainer -->|"builds models"| node_architectures
node_trainer -->|"evaluates models"| node_metrics
node_researcher -->|"trains models"| node_trainer
node_memorization -->|"loads samples"| node_data_loader
node_memorization -->|"builds detector"| node_architectures
node_memorization -->|"measures AP"| node_metrics
node_predict -->|"uses models"| node_architectures
node_predict -->|"associates detections"| node_association
node_error_review -->|"loads validation"| node_data_loader
node_error_review -->|"runs detector"| node_architectures
node_error_review -->|"proposes links"| node_association
node_relation_eval -->|"evaluates proposals"| node_association
node_relation_eval -->|"validates references"| node_validate

click node_audit "https://github.com/makebuz/moto-detector/blob/main/scripts/audit-dataset.mjs"
click node_prepare "https://github.com/makebuz/moto-detector/blob/main/scripts/prepare-dataset.mjs"
click node_utils "https://github.com/makebuz/moto-detector/blob/main/scripts/dataset-utils.mjs"
click node_verify "https://github.com/makebuz/moto-detector/blob/main/scripts/verify-prepared-dataset.mjs"
click node_batch "https://github.com/makebuz/moto-detector/blob/main/training/build_training_annotation_batch.py"
click node_validate "https://github.com/makebuz/moto-detector/blob/main/training/validate_annotation_batch.py"
click node_labels "https://github.com/makebuz/moto-detector/blob/main/training/prepare_separate_labels.py"
click node_consolidate "https://github.com/makebuz/moto-detector/blob/main/training/consolidate_separate_dataset.py"
click node_annotations "https://github.com/makebuz/moto-detector/tree/main/data/annotations"
click node_data_loader "https://github.com/makebuz/moto-detector/blob/main/training/data.py"
click node_architectures "https://github.com/makebuz/moto-detector/blob/main/training/models.py"
click node_trainer "https://github.com/makebuz/moto-detector/blob/main/training/train.py"
click node_metrics "https://github.com/makebuz/moto-detector/blob/main/training/metrics.py"
click node_memorization "https://github.com/makebuz/moto-detector/blob/main/training/overfit_heads.py"
click node_predict "https://github.com/makebuz/moto-detector/blob/main/training/predict.py"
click node_association "https://github.com/makebuz/moto-detector/blob/main/training/association.py"
click node_error_review "https://github.com/makebuz/moto-detector/blob/main/training/review_errors.py"
click node_relation_eval "https://github.com/makebuz/moto-detector/blob/main/training/evaluate_relations.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_audit,node_prepare,node_utils,node_verify toneBlue
class node_batch,node_validate,node_labels,node_consolidate,node_annotations toneAmber
class node_data_loader,node_architectures,node_trainer,node_metrics,node_memorization toneMint
class node_predict,node_association,node_error_review,node_relation_eval toneRose
class node_researcher,node_human toneIndigo
```

## Components

### Data preparation

- [Dataset audit](https://github.com/makebuz/moto-detector/blob/main/scripts/audit-dataset.mjs): `scripts/audit-dataset.mjs`
- [Dataset preparation](https://github.com/makebuz/moto-detector/blob/main/scripts/prepare-dataset.mjs): `scripts/prepare-dataset.mjs`
- [Dataset utilities](https://github.com/makebuz/moto-detector/blob/main/scripts/dataset-utils.mjs): `scripts/dataset-utils.mjs`
- [Dataset verification](https://github.com/makebuz/moto-detector/blob/main/scripts/verify-prepared-dataset.mjs): `scripts/verify-prepared-dataset.mjs`

### Human review

- [Annotation batches](https://github.com/makebuz/moto-detector/blob/main/training/build_training_annotation_batch.py): `training/build_training_annotation_batch.py`
- [Review validation](https://github.com/makebuz/moto-detector/blob/main/training/validate_annotation_batch.py): `training/validate_annotation_batch.py`
- [Label conversion](https://github.com/makebuz/moto-detector/blob/main/training/prepare_separate_labels.py): `training/prepare_separate_labels.py`
- [Dataset consolidation](https://github.com/makebuz/moto-detector/blob/main/training/consolidate_separate_dataset.py): `training/consolidate_separate_dataset.py`
- [Reviewed annotations](https://github.com/makebuz/moto-detector/tree/main/data/annotations): `data/annotations`

### Modeling and evaluation

- [Training data](https://github.com/makebuz/moto-detector/blob/main/training/data.py): `training/data.py`
- [Model architectures](https://github.com/makebuz/moto-detector/blob/main/training/models.py): `training/models.py`
- [Training and validation](https://github.com/makebuz/moto-detector/blob/main/training/train.py): `training/train.py`
- [Detection metrics](https://github.com/makebuz/moto-detector/blob/main/training/metrics.py): `training/metrics.py`
- [Head diagnostics](https://github.com/makebuz/moto-detector/blob/main/training/overfit_heads.py): `training/overfit_heads.py`

### Prediction analysis

- [Prediction](https://github.com/makebuz/moto-detector/blob/main/training/predict.py): `training/predict.py`
- [Geometric association](https://github.com/makebuz/moto-detector/blob/main/training/association.py): `training/association.py`
- [Error review](https://github.com/makebuz/moto-detector/blob/main/training/review_errors.py): `training/review_errors.py`
- [Relation evaluation](https://github.com/makebuz/moto-detector/blob/main/training/evaluate_relations.py): `training/evaluate_relations.py`

### Other components

- **Researcher**
- **Human annotator**

## Connections

- Researcher → Dataset audit: audits data (evidence: `README.md`)
- Researcher → Dataset preparation: prepares data (evidence: `README.md`)
- Dataset preparation → Dataset utilities: uses utilities (evidence: `scripts/prepare-dataset.mjs`)
- Researcher → Annotation batches: starts review (evidence: `README.md`)
- Annotation batches → Human annotator: queues images (evidence: `training/build_training_annotation_batch.py`)
- Human annotator → Reviewed annotations: reviews labels (evidence: `README.md`)
- Review validation → Reviewed annotations: validates review (evidence: `training/validate_annotation_batch.py`)
- Dataset consolidation → Review validation: validates batches (evidence: `training/consolidate_separate_dataset.py`)
- Dataset consolidation → Label conversion: converts labels (evidence: `training/consolidate_separate_dataset.py`)
- Researcher → Dataset verification: verifies dataset (evidence: `README.md`)
- Training and validation → Training data: loads samples (evidence: `training/train.py`)
- Training and validation → Model architectures: builds models (evidence: `training/train.py`)
- Training and validation → Detection metrics: evaluates models (evidence: `training/train.py`)
- Researcher → Training and validation: trains models (evidence: `README.md`)
- Head diagnostics → Training data: loads samples (evidence: `training/overfit_heads.py`)
- Head diagnostics → Model architectures: builds detector (evidence: `training/overfit_heads.py`)
- Head diagnostics → Detection metrics: measures AP (evidence: `training/overfit_heads.py`)
- Prediction → Model architectures: uses models (evidence: `training/predict.py`)
- Prediction → Geometric association: associates detections (evidence: `training/predict.py`)
- Error review → Training data: loads validation (evidence: `training/review_errors.py`)
- Error review → Model architectures: runs detector (evidence: `training/review_errors.py`)
- Error review → Geometric association: proposes links (evidence: `training/review_errors.py`)
- Relation evaluation → Geometric association: evaluates proposals (evidence: `training/evaluate_relations.py`)
- Relation evaluation → Review validation: validates references (evidence: `training/evaluate_relations.py`)
