# accidentbench/accident architecture

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

- Interactive diagram: https://gitdiagram.com/accidentbench/accident
- Repository: https://github.com/accidentbench/accident

## Overview

ACCIDENT combines an accident-video dataset and baseline experiments with a CARLA synthetic-data pipeline. The paper-reproduction workflow is to prepare the dataset, load its metadata and videos, run a heuristic or temporal vision-language baseline, and save predictions for evaluation. Separately, scenario configurations drive CARLA runs that produce annotated synthetic images or videos. The graph includes documented spatial/classification experiments and the generation pipeline’s indexed core modules; links for unsampled capabilities rely on README statements or indexed references, not inspection of their full implementations.

Main entry points: [`generation/carla-simulation/src/client/core/synthesizer.py`](https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/synthesizer.py) (Simulation Control), [`baselines/llm/baselines/temporal/main.py`](https://github.com/accidentbench/accident/blob/main/baselines/llm/baselines/temporal/main.py) (Temporal Runner), [`generation/carla-simulation/src/client/runner.py`](https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/runner.py) (Scenario Runner), [`generation/carla-simulation/src/client/core/hooks.py`](https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/hooks.py) (Simulation Hooks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Dataset"]
  node_dataset_prep["Dataset Preparation"]
  node_dataset_layout[("Dataset Layout")]
  node_dataset_access["Dataset Resolver"]
end

subgraph group_heuristic["Heuristic Baselines"]
  node_naive["Naive Baseline<br/>[naive.py]"]
  node_optical_flow["Optical Flow<br/>[optical_flow.py]"]
  node_bbox_dynamics["Box Dynamics<br/>[bbox_dynamics.py]"]
  node_metrics["Evaluation Metrics<br/>[metrics.py]"]
end

subgraph group_llm["LLM/VLM Baselines"]
  node_llm_experiments["Spatial &amp; Classification"]
  node_temporal_main["Temporal Runner<br/>[main.py]"]
  node_frame_utils["Frame Utilities<br/>[utils.py]"]
  node_qwen["Qwen Reasoner<br/>[qwen.py]"]
  node_molmo["Molmo Reasoner<br/>[molmo.py]"]
end

subgraph group_generation["Synthetic Generation"]
  node_scenario_config["Scenario Templates<br/>[scenario.py]"]
  node_cli["Generation CLI<br/>[main.py]"]
  node_runner["Scenario Runner<br/>[runner.py]"]
end

subgraph group_carla_core["CARLA Runtime"]
  node_synthesizer["Simulation Control<br/>[synthesizer.py]"]
  node_actors["Actor Setup<br/>[actors.py]"]
  node_sensors["Sensor Capture<br/>[sensors.py]"]
  node_sync["Frame Synchronization"]
  node_hooks["Simulation Hooks<br/>[hooks.py]"]
  node_collisions["Collision Evaluation<br/>[collisions.py]"]
  node_bbox["Bounding Boxes"]
  node_annotator["Annotation Writers<br/>[carla_annotator.py]"]
  node_io["Output Utilities<br/>[ioutils.py]"]
  node_carla_utils["CARLA Utilities<br/>[carlautils.py]"]
  node_gui["Simulation Display<br/>[gui_window.py]"]
  node_logging["Logging<br/>[log.py]"]
end

node_researcher(("Researcher"))
node_simulator["CARLA Simulator"]

node_researcher -->|"downloads data"| node_dataset_prep
node_dataset_prep -->|"prepares layout"| node_dataset_layout
node_researcher -->|"runs baseline"| node_naive
node_researcher -->|"runs baseline"| node_optical_flow
node_researcher -->|"runs baseline"| node_bbox_dynamics
node_naive -->|"loads dataset"| node_dataset_access
node_optical_flow -->|"loads dataset"| node_dataset_access
node_bbox_dynamics -->|"loads dataset"| node_dataset_access
node_naive -->|"uses metrics"| node_metrics
node_optical_flow -->|"uses metrics"| node_metrics
node_bbox_dynamics -->|"uses metrics"| node_metrics
node_researcher -->|"runs experiments"| node_llm_experiments
node_researcher -->|"runs temporal task"| node_temporal_main
node_temporal_main -->|"resolves dataset"| node_dataset_access
node_temporal_main -->|"samples frames"| node_frame_utils
node_temporal_main -->|"selects reasoner"| node_qwen
node_temporal_main -->|"selects reasoner"| node_molmo
node_researcher -->|"starts generation"| node_cli
node_cli -->|"loads scenarios"| node_scenario_config
node_cli -->|"starts runner"| node_runner
node_runner -->|"runs variants"| node_scenario_config
node_runner -->|"starts synthesis"| node_synthesizer
node_runner -->|"sets up annotator"| node_annotator
node_runner -->|"connects to"| node_simulator
node_synthesizer -->|"controls simulation"| node_simulator
node_synthesizer -->|"sets up actors"| node_actors
node_synthesizer -->|"sets up sensors"| node_sensors
node_synthesizer -->|"synchronizes frames"| node_sync
node_synthesizer -->|"uses hooks"| node_hooks
node_synthesizer -->|"evaluates collisions"| node_collisions
node_synthesizer -->|"processes segmentation"| node_bbox
node_synthesizer -->|"writes annotations"| node_annotator
node_synthesizer -->|"displays frames"| node_gui
node_synthesizer -->|"logs activity"| node_logging
node_bbox -->|"uses transforms"| node_carla_utils
node_annotator -->|"uses file utilities"| node_io
node_hooks -->|"uses actors"| node_actors
node_hooks -->|"uses sensors"| node_sensors
node_hooks -->|"uses synchronization"| node_sync
node_collisions -->|"inspects actors"| node_actors
node_collisions -->|"uses boxes"| node_bbox

click node_dataset_prep "https://github.com/accidentbench/accident/blob/main/dataset/download_dataset.sh"
click node_dataset_layout "https://github.com/accidentbench/accident/tree/main/dataset"
click node_dataset_access "https://github.com/accidentbench/accident/blob/main/dataset/accident_dataset.py"
click node_naive "https://github.com/accidentbench/accident/blob/main/baselines/heuristic/naive.py"
click node_optical_flow "https://github.com/accidentbench/accident/blob/main/baselines/heuristic/optical_flow.py"
click node_bbox_dynamics "https://github.com/accidentbench/accident/blob/main/baselines/heuristic/bbox_dynamics.py"
click node_metrics "https://github.com/accidentbench/accident/blob/main/baselines/heuristic/metrics.py"
click node_llm_experiments "https://github.com/accidentbench/accident/tree/main/baselines/llm/baselines"
click node_temporal_main "https://github.com/accidentbench/accident/blob/main/baselines/llm/baselines/temporal/main.py"
click node_frame_utils "https://github.com/accidentbench/accident/blob/main/baselines/llm/reasoning/utils.py"
click node_qwen "https://github.com/accidentbench/accident/blob/main/baselines/llm/reasoning/qwen.py"
click node_molmo "https://github.com/accidentbench/accident/blob/main/baselines/llm/reasoning/molmo.py"
click node_scenario_config "https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/scenario.py"
click node_cli "https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/main.py"
click node_runner "https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/runner.py"
click node_synthesizer "https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/synthesizer.py"
click node_actors "https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/actors.py"
click node_sensors "https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/sensors.py"
click node_sync "https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/synchronous_mode.py"
click node_hooks "https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/hooks.py"
click node_collisions "https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/collisions.py"
click node_bbox "https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/bbox_segmentation.py"
click node_annotator "https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/carla_annotator.py"
click node_io "https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/ioutils.py"
click node_carla_utils "https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/carlautils.py"
click node_gui "https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/gui_window.py"
click node_logging "https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/log.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_dataset_prep,node_dataset_layout,node_dataset_access toneBlue
class node_naive,node_optical_flow,node_bbox_dynamics,node_metrics toneAmber
class node_llm_experiments,node_temporal_main,node_frame_utils,node_qwen,node_molmo toneMint
class node_scenario_config,node_cli,node_runner toneRose
class node_synthesizer,node_actors,node_sensors,node_sync,node_hooks,node_collisions,node_bbox,node_annotator,node_io,node_carla_utils,node_gui,node_logging,node_researcher,node_simulator toneIndigo
```

## Components

### Dataset

- [Dataset Preparation](https://github.com/accidentbench/accident/blob/main/dataset/download_dataset.sh): `dataset/download_dataset.sh`
- [Dataset Layout](https://github.com/accidentbench/accident/tree/main/dataset): `dataset`
- [Dataset Resolver](https://github.com/accidentbench/accident/blob/main/dataset/accident_dataset.py): `dataset/accident_dataset.py`

### Heuristic Baselines

- [Naive Baseline](https://github.com/accidentbench/accident/blob/main/baselines/heuristic/naive.py): `baselines/heuristic/naive.py`
- [Optical Flow](https://github.com/accidentbench/accident/blob/main/baselines/heuristic/optical_flow.py): `baselines/heuristic/optical_flow.py`
- [Box Dynamics](https://github.com/accidentbench/accident/blob/main/baselines/heuristic/bbox_dynamics.py): `baselines/heuristic/bbox_dynamics.py`
- [Evaluation Metrics](https://github.com/accidentbench/accident/blob/main/baselines/heuristic/metrics.py): `baselines/heuristic/metrics.py`

### LLM/VLM Baselines

- [Spatial & Classification](https://github.com/accidentbench/accident/tree/main/baselines/llm/baselines): `baselines/llm/baselines`
- [Temporal Runner](https://github.com/accidentbench/accident/blob/main/baselines/llm/baselines/temporal/main.py): `baselines/llm/baselines/temporal/main.py`
- [Frame Utilities](https://github.com/accidentbench/accident/blob/main/baselines/llm/reasoning/utils.py): `baselines/llm/reasoning/utils.py`
- [Qwen Reasoner](https://github.com/accidentbench/accident/blob/main/baselines/llm/reasoning/qwen.py): `baselines/llm/reasoning/qwen.py`
- [Molmo Reasoner](https://github.com/accidentbench/accident/blob/main/baselines/llm/reasoning/molmo.py): `baselines/llm/reasoning/molmo.py`

### Synthetic Generation

- [Scenario Templates](https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/scenario.py): `generation/carla-simulation/src/client/scenario.py`
- [Generation CLI](https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/main.py): `generation/carla-simulation/src/client/main.py`
- [Scenario Runner](https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/runner.py): `generation/carla-simulation/src/client/runner.py`

### CARLA Runtime

- [Simulation Control](https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/synthesizer.py): `generation/carla-simulation/src/client/core/synthesizer.py`
- [Actor Setup](https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/actors.py): `generation/carla-simulation/src/client/core/actors.py`
- [Sensor Capture](https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/sensors.py): `generation/carla-simulation/src/client/core/sensors.py`
- [Frame Synchronization](https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/synchronous_mode.py): `generation/carla-simulation/src/client/core/synchronous_mode.py`
- [Simulation Hooks](https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/hooks.py): `generation/carla-simulation/src/client/core/hooks.py`
- [Collision Evaluation](https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/collisions.py): `generation/carla-simulation/src/client/core/collisions.py`
- [Bounding Boxes](https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/bbox_segmentation.py): `generation/carla-simulation/src/client/core/bbox_segmentation.py`
- [Annotation Writers](https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/carla_annotator.py): `generation/carla-simulation/src/client/core/carla_annotator.py`
- [Output Utilities](https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/ioutils.py): `generation/carla-simulation/src/client/core/ioutils.py`
- [CARLA Utilities](https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/carlautils.py): `generation/carla-simulation/src/client/core/carlautils.py`
- [Simulation Display](https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/gui_window.py): `generation/carla-simulation/src/client/core/gui_window.py`
- [Logging](https://github.com/accidentbench/accident/blob/main/generation/carla-simulation/src/client/core/log.py): `generation/carla-simulation/src/client/core/log.py`

### Other components

- **Researcher**
- **CARLA Simulator**

## Connections

- Researcher → Dataset Preparation: downloads data (evidence: `README.md`)
- Dataset Preparation → Dataset Layout: prepares layout (evidence: `README.md`)
- Researcher → Naive Baseline: runs baseline (evidence: `README.md`)
- Researcher → Optical Flow: runs baseline (evidence: `README.md`)
- Researcher → Box Dynamics: runs baseline (evidence: `README.md`)
- Naive Baseline → Dataset Resolver: loads dataset (evidence: `baselines/heuristic/naive.py`)
- Optical Flow → Dataset Resolver: loads dataset (evidence: `baselines/heuristic/optical_flow.py`)
- Box Dynamics → Dataset Resolver: loads dataset (evidence: `baselines/heuristic/bbox_dynamics.py`)
- Naive Baseline → Evaluation Metrics: uses metrics (evidence: `baselines/heuristic/naive.py`)
- Optical Flow → Evaluation Metrics: uses metrics (evidence: `baselines/heuristic/optical_flow.py`)
- Box Dynamics → Evaluation Metrics: uses metrics (evidence: `baselines/heuristic/bbox_dynamics.py`)
- Researcher → Spatial & Classification: runs experiments (evidence: `README.md`)
- Researcher → Temporal Runner: runs temporal task (evidence: `README.md`)
- Temporal Runner → Dataset Resolver: resolves dataset (evidence: `baselines/llm/baselines/temporal/main.py`)
- Temporal Runner → Frame Utilities: samples frames (evidence: `baselines/llm/baselines/temporal/main.py`)
- Temporal Runner → Qwen Reasoner: selects reasoner (evidence: `baselines/llm/baselines/temporal/main.py`)
- Temporal Runner → Molmo Reasoner: selects reasoner (evidence: `baselines/llm/baselines/temporal/main.py`)
- Researcher → Generation CLI: starts generation (evidence: `README.md`)
- Generation CLI → Scenario Templates: loads scenarios (evidence: `generation/carla-simulation/src/client/main.py`)
- Generation CLI → Scenario Runner: starts runner (evidence: `generation/carla-simulation/src/client/main.py`)
- Scenario Runner → Scenario Templates: runs variants (evidence: `generation/carla-simulation/src/client/runner.py`)
- Scenario Runner → Simulation Control: starts synthesis (evidence: `generation/carla-simulation/src/client/runner.py`)
- Scenario Runner → Annotation Writers: sets up annotator (evidence: `generation/carla-simulation/src/client/runner.py`)
- Scenario Runner → CARLA Simulator: connects to (evidence: `generation/carla-simulation/src/client/runner.py`)
- Simulation Control → CARLA Simulator: controls simulation (evidence: `generation/carla-simulation/src/client/core/synthesizer.py`)
- Simulation Control → Actor Setup: sets up actors (evidence: `generation/carla-simulation/src/client/core/synthesizer.py`)
- Simulation Control → Sensor Capture: sets up sensors (evidence: `generation/carla-simulation/src/client/core/synthesizer.py`)
- Simulation Control → Frame Synchronization: synchronizes frames (evidence: `generation/carla-simulation/src/client/core/synthesizer.py`)
- Simulation Control → Simulation Hooks: uses hooks (evidence: `generation/carla-simulation/src/client/core/synthesizer.py`)
- Simulation Control → Collision Evaluation: evaluates collisions (evidence: `generation/carla-simulation/src/client/core/synthesizer.py`)
- Simulation Control → Bounding Boxes: processes segmentation (evidence: `generation/carla-simulation/src/client/core/synthesizer.py`)
- Simulation Control → Annotation Writers: writes annotations (evidence: `generation/carla-simulation/src/client/core/synthesizer.py`)
- Simulation Control → Simulation Display: displays frames (evidence: `generation/carla-simulation/src/client/core/synthesizer.py`)
- Simulation Control → Logging: logs activity (evidence: `generation/carla-simulation/src/client/core/synthesizer.py`)
- Bounding Boxes → CARLA Utilities: uses transforms (evidence: `generation/carla-simulation/src/client/core/bbox_segmentation.py`)
- Annotation Writers → Output Utilities: uses file utilities (evidence: `generation/carla-simulation/src/client/core/carla_annotator.py`)
- Simulation Hooks → Actor Setup: uses actors (evidence: `generation/carla-simulation/src/client/core/hooks.py`)
- Simulation Hooks → Sensor Capture: uses sensors (evidence: `generation/carla-simulation/src/client/core/hooks.py`)
- Simulation Hooks → Frame Synchronization: uses synchronization (evidence: `generation/carla-simulation/src/client/core/hooks.py`)
- Collision Evaluation → Actor Setup: inspects actors (evidence: `generation/carla-simulation/src/client/core/collisions.py`)
- Collision Evaluation → Bounding Boxes: uses boxes (evidence: `generation/carla-simulation/src/client/core/collisions.py`)
