# amap-cvlab/abot-recon architecture

> Architecture diagram of the GitHub repository amap-cvlab/abot-recon, 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/amap-cvlab/abot-recon
- Repository: https://github.com/amap-cvlab/abot-recon

## Overview

ABot-Recon is a Python inference product for long video streams: users provide ordered images through the API or CLI, which preprocesses frames, runs a fixed-context streaming model, composes camera poses, and returns trajectory and optional point/confidence outputs. An optional loop-closure branch retrieves revisited frames, estimates pose constraints, and refines the trajectory. Streaming internals include windowed attention and KV state. The README documents the product stages; some subsystem links below are documented rather than verified in sampled implementation excerpts.

Main entry points: [`abot_recon/modeling/streaming/network.py`](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/modeling/streaming/network.py) (Streaming network), [`abot_recon/api.py`](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/api.py) (Python API), [`abot_recon/loop_closure.py`](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/loop_closure.py) (Loop refinement), [`abot_recon/model.py`](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/model.py) (Inference runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_cli["CLI<br/>[cli.py]"]
  node_api["Python API<br/>[api.py]"]
end

subgraph group_inference["Reconstruction inference"]
  node_preprocess["Frame preprocessing<br/>[preprocessing.py]"]
  node_checkpoint["Checkpoint loading<br/>[checkpoint.py]"]
  node_runtime["Inference runtime<br/>[model.py]"]
  node_geometry["Pose composition<br/>[geometry.py]"]
  node_result["Reconstruction result<br/>[types.py]"]
end

subgraph group_streaming["Streaming model"]
  node_network["Streaming network<br/>[network.py]"]
  node_pi3["Geometry predictor<br/>[pi3.py]"]
  node_attention["Streaming attention<br/>[attention.py]"]
  node_chunk["Chunk attention<br/>[chunk_attention.py]"]
  node_window["Window masks<br/>[window_mask.py]"]
  node_kv["KV state<br/>[kv_state.py]"]
  node_paged["Paged KV<br/>[paged_kv.py]"]
  node_rope["3D rotary positions<br/>[rope3d.py]"]
  node_sdpa["SDPA backend<br/>[sdpa.py]"]
end

subgraph group_loop["Loop closure"]
  node_loopctl["Loop refinement<br/>[loop_closure.py]"]
  node_retrieval["Frame retrieval<br/>[retrieval.py]"]
  node_keyframes["Sparse keyframes"]
  node_graph["Pose graph<br/>[graph.py]"]
  node_optimizer["Graph optimizer<br/>[gpu_pgo.py]"]
  node_assets["Retrieval assets<br/>[assets.py]"]
end

node_user(("Image sequence"))

node_user -->|"provides frames"| node_cli
node_user -->|"provides frames"| node_api
node_cli -->|"invokes inference"| node_api
node_api -->|"prepares frames"| node_preprocess
node_api -->|"runs model"| node_runtime
node_api -->|"resolves weights"| node_checkpoint
node_runtime -->|"loads weights"| node_checkpoint
node_runtime -->|"constructs network"| node_network
node_runtime -->|"consumes frames"| node_preprocess
node_network -->|"predicts geometry"| node_pi3
node_network -->|"dispatches attention"| node_attention
node_network -->|"maintains state"| node_kv
node_network -->|"uses cache backend"| node_paged
node_network -->|"runs chunk attention"| node_chunk
node_network -->|"builds positions"| node_rope
node_network -->|"uses fallback"| node_sdpa
node_attention -->|"delegates chunks"| node_chunk
node_chunk -->|"applies masks"| node_window
node_runtime -->|"composes poses"| node_geometry
node_api -->|"optionally refines"| node_loopctl
node_loopctl -->|"retrieves candidates"| node_retrieval
node_loopctl -->|"selects keyframes"| node_keyframes
node_loopctl -->|"builds constraints"| node_graph
node_graph -->|"optimizes graph"| node_optimizer
node_loopctl -->|"loads assets"| node_assets
node_api -->|"returns outputs"| node_result
node_loopctl -.->|"estimates loop poses"| node_runtime

click node_cli "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/cli.py"
click node_api "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/api.py"
click node_preprocess "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/preprocessing.py"
click node_checkpoint "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/checkpoint.py"
click node_runtime "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/model.py"
click node_network "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/modeling/streaming/network.py"
click node_pi3 "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/modeling/pi3/models/pi3.py"
click node_attention "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/modeling/streaming/attention.py"
click node_chunk "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/modeling/streaming/core/chunk_attention.py"
click node_window "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/modeling/streaming/core/window_mask.py"
click node_kv "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/modeling/streaming/kv_state.py"
click node_paged "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/modeling/streaming/paged_kv.py"
click node_rope "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/modeling/streaming/rope3d.py"
click node_sdpa "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/modeling/streaming/sdpa.py"
click node_geometry "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/geometry.py"
click node_result "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/types.py"
click node_loopctl "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/loop_closure.py"
click node_retrieval "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/sparse_loop/retrieval.py"
click node_keyframes "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/sparse_loop/sparse_keyframes.py"
click node_graph "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/sparse_loop/graph.py"
click node_optimizer "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/sparse_loop/gpu_pgo.py"
click node_assets "https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/sparse_loop/assets.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_cli,node_api toneBlue
class node_preprocess,node_checkpoint,node_runtime,node_geometry,node_result toneAmber
class node_network,node_pi3,node_attention,node_chunk,node_window,node_kv,node_paged,node_rope,node_sdpa toneMint
class node_loopctl,node_retrieval,node_keyframes,node_graph,node_optimizer,node_assets toneRose
class node_user toneIndigo
```

## Components

### User interface

- [CLI](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/cli.py): `abot_recon/cli.py`
- [Python API](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/api.py): `abot_recon/api.py`

### Reconstruction inference

- [Frame preprocessing](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/preprocessing.py): `abot_recon/preprocessing.py`
- [Checkpoint loading](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/checkpoint.py): `abot_recon/checkpoint.py`
- [Inference runtime](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/model.py): `abot_recon/model.py`
- [Pose composition](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/geometry.py): `abot_recon/geometry.py`
- [Reconstruction result](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/types.py): `abot_recon/types.py`

### Streaming model

- [Streaming network](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/modeling/streaming/network.py): `abot_recon/modeling/streaming/network.py`
- [Geometry predictor](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/modeling/pi3/models/pi3.py): `abot_recon/modeling/pi3/models/pi3.py`
- [Streaming attention](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/modeling/streaming/attention.py): `abot_recon/modeling/streaming/attention.py`
- [Chunk attention](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/modeling/streaming/core/chunk_attention.py): `abot_recon/modeling/streaming/core/chunk_attention.py`
- [Window masks](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/modeling/streaming/core/window_mask.py): `abot_recon/modeling/streaming/core/window_mask.py`
- [KV state](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/modeling/streaming/kv_state.py): `abot_recon/modeling/streaming/kv_state.py`
- [Paged KV](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/modeling/streaming/paged_kv.py): `abot_recon/modeling/streaming/paged_kv.py`
- [3D rotary positions](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/modeling/streaming/rope3d.py): `abot_recon/modeling/streaming/rope3d.py`
- [SDPA backend](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/modeling/streaming/sdpa.py): `abot_recon/modeling/streaming/sdpa.py`

### Loop closure

- [Loop refinement](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/loop_closure.py): `abot_recon/loop_closure.py`
- [Frame retrieval](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/sparse_loop/retrieval.py): `abot_recon/sparse_loop/retrieval.py`
- [Sparse keyframes](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/sparse_loop/sparse_keyframes.py): `abot_recon/sparse_loop/sparse_keyframes.py`
- [Pose graph](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/sparse_loop/graph.py): `abot_recon/sparse_loop/graph.py`
- [Graph optimizer](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/sparse_loop/gpu_pgo.py): `abot_recon/sparse_loop/gpu_pgo.py`
- [Retrieval assets](https://github.com/amap-cvlab/abot-recon/blob/main/abot_recon/sparse_loop/assets.py): `abot_recon/sparse_loop/assets.py`

### Other components

- **Image sequence**

## Connections

- Image sequence → CLI: provides frames (evidence: `README.md`)
- Image sequence → Python API: provides frames (evidence: `README.md`)
- CLI → Python API: invokes inference (evidence: `abot_recon/cli.py`)
- Python API → Frame preprocessing: prepares frames (evidence: `abot_recon/api.py`)
- Python API → Inference runtime: runs model (evidence: `abot_recon/api.py`)
- Python API → Checkpoint loading: resolves weights (evidence: `abot_recon/api.py`)
- Inference runtime → Checkpoint loading: loads weights (evidence: `abot_recon/model.py`)
- Inference runtime → Streaming network: constructs network (evidence: `abot_recon/model.py`)
- Inference runtime → Frame preprocessing: consumes frames (evidence: `abot_recon/model.py`)
- Streaming network → Geometry predictor: predicts geometry (evidence: `abot_recon/modeling/streaming/network.py`)
- Streaming network → Streaming attention: dispatches attention (evidence: `abot_recon/modeling/streaming/network.py`)
- Streaming network → KV state: maintains state (evidence: `abot_recon/modeling/streaming/network.py`)
- Streaming network → Paged KV: uses cache backend (evidence: `abot_recon/modeling/streaming/network.py`)
- Streaming network → Chunk attention: runs chunk attention (evidence: `abot_recon/modeling/streaming/network.py`)
- Streaming network → 3D rotary positions: builds positions (evidence: `abot_recon/modeling/streaming/network.py`)
- Streaming network → SDPA backend: uses fallback (evidence: `abot_recon/modeling/streaming/network.py`)
- Streaming attention → Chunk attention: delegates chunks (evidence: `abot_recon/modeling/streaming/attention.py`)
- Chunk attention → Window masks: applies masks (evidence: `abot_recon/modeling/streaming/core/chunk_attention.py`)
- Inference runtime → Pose composition: composes poses (evidence: `abot_recon/api.py`)
- Python API → Loop refinement: optionally refines (evidence: `abot_recon/api.py`)
- Loop refinement → Frame retrieval: retrieves candidates (evidence: `abot_recon/loop_closure.py`)
- Loop refinement → Sparse keyframes: selects keyframes (evidence: `abot_recon/loop_closure.py`)
- Loop refinement → Pose graph: builds constraints (evidence: `abot_recon/loop_closure.py`)
- Pose graph → Graph optimizer: optimizes graph (evidence: `abot_recon/sparse_loop/graph.py`)
- Loop refinement → Retrieval assets: loads assets (evidence: `abot_recon/loop_closure.py`)
- Python API → Reconstruction result: returns outputs (evidence: `abot_recon/api.py`)
- Loop refinement → Inference runtime: estimates loop poses (evidence: `README.md`)
