# 3dagentworld/horizonstream architecture

> Architecture diagram of the GitHub repository 3dagentworld/horizonstream, 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/3dagentworld/horizonstream
- Repository: https://github.com/3dagentworld/horizonstream

## Overview

HorizonStream is an online RGB-video and image-sequence reconstruction system. The principal workflow loads and preprocesses frames, performs windowed streaming model inference, and exports camera poses, depth, confidence, and point clouds; optional loop closure and trajectory evaluation extend the results. The graph also preserves documented conversion, depth-fusion, and demo capabilities. Connections use the excerpts, SOURCE INDEX references, and README; several peripheral tools are documented but their implementation was not sampled.

Main entry points: [`horizonstream/core/infer.py`](https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/core/infer.py) (Inference Orchestrator), [`infer.py`](https://github.com/3dagentworld/horizonstream/blob/main/infer.py) (Inference CLI), [`horizonstream/loop/online_loop_reinfer.py`](https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/loop/online_loop_reinfer.py) (Loop Re-inference), [`run_pipeline.py`](https://github.com/3dagentworld/horizonstream/blob/main/run_pipeline.py) (Pipeline Runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and Input"]
  node_input["Video or Images"]
  node_cli["Inference CLI<br/>[infer.py]"]
  node_pipeline["Pipeline Runner<br/>[run_pipeline.py]"]
  node_loader["Sequence Loader<br/>[dataloader.py]"]
end

subgraph group_model["Streaming Reconstruction"]
  node_modelwrap["Model Wrapper<br/>[model.py]"]
  node_architecture["HorizonStream Model<br/>[horizonstream.py]"]
  node_streammodel["Streaming Network<br/>[horizonstream.py]"]
  node_aggregator["Window Aggregator<br/>[aggregator.py]"]
  node_layers["Attention Blocks<br/>[block.py]"]
  node_camera["Camera Head<br/>[camera_head.py]"]
end

subgraph group_results["Results and Evaluation"]
  node_inference["Inference Orchestrator<br/>[infer.py]"]
  node_averaging["Motion Averaging"]
  node_posefiles["Pose Export<br/>[save_poses_txt.py]"]
  node_pointfiles["Point Cloud Export<br/>[save_points.py]"]
  node_imagefiles["Image Export<br/>[save_images.py]"]
  node_evaluation["Trajectory Evaluation<br/>[trajectory.py]"]
end

subgraph group_loop["Loop Closure"]
  node_loopentry["Loop Re-inference"]
  node_loopruntime["Loop Detection and Optimization<br/>[runtime.py]"]
end

subgraph group_tools["Utilities and Demos"]
  node_demo["Interactive Demos"]
  node_converters["Dataset Converters"]
  node_depthfusion["Depth Fusion"]
end

node_user(("User"))

node_user -->|"runs inference"| node_cli
node_input -->|"provides frames"| node_cli
node_cli -->|"starts inference"| node_inference
node_cli -->|"runs optional loop"| node_loopentry
node_pipeline -->|"runs inference"| node_inference
node_pipeline -->|"evaluates results"| node_evaluation
node_pipeline -->|"runs optional loop"| node_loopentry
node_inference -->|"loads sequences"| node_loader
node_inference -->|"invokes model"| node_modelwrap
node_modelwrap -->|"constructs model"| node_architecture
node_architecture -->|"decodes cameras"| node_camera
node_architecture -->|"uses network"| node_streammodel
node_streammodel -->|"aggregates features"| node_aggregator
node_aggregator -->|"uses blocks"| node_layers
node_inference -->|"averages poses"| node_averaging
node_inference -->|"writes poses"| node_posefiles
node_inference -->|"writes point clouds"| node_pointfiles
node_inference -->|"writes images"| node_imagefiles
node_loopentry -->|"detects and optimizes"| node_loopruntime
node_loopentry -->|"writes loop clouds"| node_pointfiles
node_evaluation -->|"reads loop results"| node_loopruntime
node_demo -.->|"visualizes reconstruction"| node_input
node_user -.->|"opens demo"| node_demo
node_user -.->|"converts datasets"| node_converters
node_pointfiles -.->|"supplies point data"| node_depthfusion

click node_cli "https://github.com/3dagentworld/horizonstream/blob/main/infer.py"
click node_pipeline "https://github.com/3dagentworld/horizonstream/blob/main/run_pipeline.py"
click node_loader "https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/data/dataloader.py"
click node_modelwrap "https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/core/model.py"
click node_architecture "https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/models/horizonstream.py"
click node_streammodel "https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/runtime/models/horizonstream.py"
click node_aggregator "https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/runtime/models/aggregator.py"
click node_layers "https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/runtime/layers/block.py"
click node_camera "https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/runtime/heads/camera_head.py"
click node_inference "https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/core/infer.py"
click node_averaging "https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/runtime/motion_averaging.py"
click node_posefiles "https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/io/save_poses_txt.py"
click node_pointfiles "https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/io/save_points.py"
click node_imagefiles "https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/io/save_images.py"
click node_evaluation "https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/eval/trajectory.py"
click node_loopentry "https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/loop/online_loop_reinfer.py"
click node_loopruntime "https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/loop/runtime.py"
click node_demo "https://github.com/3dagentworld/horizonstream/blob/main/demo_gradio_viser.py"
click node_converters "https://github.com/3dagentworld/horizonstream/blob/main/scripts/kitti_to_generalizable.py"
click node_depthfusion "https://github.com/3dagentworld/horizonstream/blob/main/scripts/post_depthfusion.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_input,node_cli,node_pipeline,node_loader,node_user toneBlue
class node_modelwrap,node_architecture,node_streammodel,node_aggregator,node_layers,node_camera toneAmber
class node_inference,node_averaging,node_posefiles,node_pointfiles,node_imagefiles,node_evaluation toneMint
class node_loopentry,node_loopruntime toneRose
class node_demo,node_converters,node_depthfusion toneIndigo
```

## Components

### Entry and Input

- **Video or Images**
- [Inference CLI](https://github.com/3dagentworld/horizonstream/blob/main/infer.py): `infer.py`
- [Pipeline Runner](https://github.com/3dagentworld/horizonstream/blob/main/run_pipeline.py): `run_pipeline.py`
- [Sequence Loader](https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/data/dataloader.py): `horizonstream/data/dataloader.py`

### Streaming Reconstruction

- [Model Wrapper](https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/core/model.py): `horizonstream/core/model.py`
- [HorizonStream Model](https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/models/horizonstream.py): `horizonstream/models/horizonstream.py`
- [Streaming Network](https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/runtime/models/horizonstream.py): `horizonstream/runtime/models/horizonstream.py`
- [Window Aggregator](https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/runtime/models/aggregator.py): `horizonstream/runtime/models/aggregator.py`
- [Attention Blocks](https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/runtime/layers/block.py): `horizonstream/runtime/layers/block.py`
- [Camera Head](https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/runtime/heads/camera_head.py): `horizonstream/runtime/heads/camera_head.py`

### Results and Evaluation

- [Inference Orchestrator](https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/core/infer.py): `horizonstream/core/infer.py`
- [Motion Averaging](https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/runtime/motion_averaging.py): `horizonstream/runtime/motion_averaging.py`
- [Pose Export](https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/io/save_poses_txt.py): `horizonstream/io/save_poses_txt.py`
- [Point Cloud Export](https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/io/save_points.py): `horizonstream/io/save_points.py`
- [Image Export](https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/io/save_images.py): `horizonstream/io/save_images.py`
- [Trajectory Evaluation](https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/eval/trajectory.py): `horizonstream/eval/trajectory.py`

### Loop Closure

- [Loop Re-inference](https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/loop/online_loop_reinfer.py): `horizonstream/loop/online_loop_reinfer.py`
- [Loop Detection and Optimization](https://github.com/3dagentworld/horizonstream/blob/main/horizonstream/loop/runtime.py): `horizonstream/loop/runtime.py`

### Utilities and Demos

- [Interactive Demos](https://github.com/3dagentworld/horizonstream/blob/main/demo_gradio_viser.py): `demo_gradio_viser.py`
- [Dataset Converters](https://github.com/3dagentworld/horizonstream/blob/main/scripts/kitti_to_generalizable.py): `scripts/kitti_to_generalizable.py`
- [Depth Fusion](https://github.com/3dagentworld/horizonstream/blob/main/scripts/post_depthfusion.py): `scripts/post_depthfusion.py`

### Other components

- **User**

## Connections

- User → Inference CLI: runs inference
- Video or Images → Inference CLI: provides frames
- Inference CLI → Inference Orchestrator: starts inference (evidence: `infer.py`)
- Inference CLI → Loop Re-inference: runs optional loop (evidence: `infer.py`)
- Pipeline Runner → Inference Orchestrator: runs inference (evidence: `run_pipeline.py`)
- Pipeline Runner → Trajectory Evaluation: evaluates results (evidence: `run_pipeline.py`)
- Pipeline Runner → Loop Re-inference: runs optional loop (evidence: `run_pipeline.py`)
- Inference Orchestrator → Sequence Loader: loads sequences (evidence: `horizonstream/core/infer.py`)
- Inference Orchestrator → Model Wrapper: invokes model (evidence: `horizonstream/core/infer.py`)
- Model Wrapper → HorizonStream Model: constructs model (evidence: `horizonstream/core/model.py`)
- HorizonStream Model → Camera Head: decodes cameras (evidence: `horizonstream/models/horizonstream.py`)
- HorizonStream Model → Streaming Network: uses network (evidence: `horizonstream/models/horizonstream.py`)
- Streaming Network → Window Aggregator: aggregates features (evidence: `horizonstream/runtime/models/horizonstream.py`)
- Window Aggregator → Attention Blocks: uses blocks (evidence: `horizonstream/runtime/models/aggregator.py`)
- Inference Orchestrator → Motion Averaging: averages poses (evidence: `horizonstream/core/infer.py`)
- Inference Orchestrator → Pose Export: writes poses (evidence: `horizonstream/core/infer.py`)
- Inference Orchestrator → Point Cloud Export: writes point clouds (evidence: `horizonstream/core/infer.py`)
- Inference Orchestrator → Image Export: writes images (evidence: `horizonstream/core/infer.py`)
- Loop Re-inference → Loop Detection and Optimization: detects and optimizes (evidence: `horizonstream/loop/online_loop_reinfer.py`)
- Loop Re-inference → Point Cloud Export: writes loop clouds (evidence: `horizonstream/loop/online_loop_reinfer.py`)
- Trajectory Evaluation → Loop Detection and Optimization: reads loop results (evidence: `horizonstream/eval/trajectory.py`)
- Interactive Demos → Video or Images: visualizes reconstruction
- User → Interactive Demos: opens demo
- User → Dataset Converters: converts datasets
- Point Cloud Export → Depth Fusion: supplies point data
