# woodfrog/maptracker architecture

> Architecture diagram of the GitHub repository woodfrog/maptracker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/woodfrog/maptracker
- Repository: https://github.com/woodfrog/maptracker

## Overview

##### Main Components

a. Input Processing Layer:
- Onboard perspective images
- Vehicle motion data (P^t_{t-1}, P^t_{t-2}, ...)
- Sensor stream inputs

b. Two Primary Modules:
##### BEV (Bird's Eye View) Module
- ConvNet feature extractor
- BEV Memory Buffer
- BEV Memory Fusion layer
- Semantic segmentation output

##### VEC (Vector) Module
- PropMLP for vector memory propagation
- Vector Memory Buffer
- Vector Memory Fusion layer
- Road element decoder

c. Memory Management System:
- Strided memory selection mechanism
- Temporal alignment system
- Memory buffers for both BEV and Vector representations

**[Input Layer]**
- ↓
**[Feature Extraction]**
- ↓
**[Parallel Processing Branches]**
- [BEV Module] ←──┐
- ↓         │
- [BEV Memory]───┘

- [VEC Module] ←──┐
- ↓          │
- [VEC Memory]────┘
- ↓
**[Road Element Reconstruction]**

##### Key Elements to Highlight

a. Memory Fusion Mechanisms:
- How BEV and Vector memories are selected and fused
- Strided memory selection process
- Demonstrate temporal connections between frames

b. Processing Pipeline:
- Parallel processing of BEV and Vector modules
- How information flows between modules
- Demonstrate the query propagation system

##### Technical Details

- Dataset interfaces (nuScenes and Argoverse2)
- Training pipeline components
- Evaluation metrics system
- Visualization components

##### Implementation Specifics

- Config management system (from plugin/configs)
- Dataset handling (from plugin/datasets)
- Model components (from plugin/models)
- Evaluation systems (from plugin/core/evaluation)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input["Input Processing Layer"]
        IMG[Onboard Images]
        VMD[Vehicle Motion Data]
        SSI[Sensor Stream Inputs]
    end

    subgraph FE["Feature Extraction"]
        CNF["ConvNet Feature Extractor"]
    end

    subgraph PB["Parallel Processing"]
        subgraph BEV["BEV Module"]
            direction TB
            TSA["Temporal Self Attention"]:::bev
            SCA["Spatial Cross Attention"]:::bev
            TRF["Transformer"]:::bev
            BMB["BEV Memory Buffer"]:::memory
            BMF["BEV Memory Fusion"]:::memory
        end

        subgraph VEC["Vector Module"]
            direction TB
            PML["PropMLP"]:::vec
            VMB["Vector Memory Buffer"]:::memory
            VMF["Vector Memory Fusion"]:::memory
            VQH["Query Handler"]:::vec
        end
    end

    subgraph MM["Memory Management"]
        SMS["Strided Memory Selection"]:::memory
        TAS["Temporal Alignment System"]:::memory
        MTF["Map Transformer"]:::memory
    end

    subgraph RER["Road Element Reconstruction"]
        MDH["Map Detector Head"]:::output
        MSH["Map Segmentation Head"]:::output
    end

    subgraph DS["Dataset System"]
        direction TB
        BD["Base Dataset"]:::data
        ND["NuScenes Dataset"]:::data
        AD["Argoverse Dataset"]:::data
    end

    subgraph EV["Evaluation System"]
        direction TB
        VE["Vector Evaluation"]:::eval
        RE["Raster Evaluation"]:::eval
        DM["Distance Metrics"]:::eval
        AP["AP Metrics"]:::eval
    end

    %% Connections
    IMG & VMD & SSI --> CNF
    CNF --> BEV
    CNF --> VEC
    
    TSA --> BMB
    SCA --> BMB
    TRF --> BMB
    BMB --> BMF
    
    PML --> VMB
    VMB --> VMF
    VQH --> VMF
    
    BMF & VMF --> MM
    MM --> RER
    
    MDH & MSH --> EV

    %% Click Events
    click TSA "https://github.com/woodfrog/maptracker/blob/main/plugin/models/backbones/bevformer/temporal_self_attention.py"
    click SCA "https://github.com/woodfrog/maptracker/blob/main/plugin/models/backbones/bevformer/spatial_cross_attention.py"
    click TRF "https://github.com/woodfrog/maptracker/blob/main/plugin/models/backbones/bevformer/transformer.py"
    click BEV "https://github.com/woodfrog/maptracker/tree/main/plugin/models/backbones/bevformer/"
    click VMB "https://github.com/woodfrog/maptracker/blob/main/plugin/models/mapers/vector_memory.py"
    click VEC "https://github.com/woodfrog/maptracker/blob/main/plugin/models/mapers/MapTracker.py"
    click MTF "https://github.com/woodfrog/maptracker/blob/main/plugin/models/transformer_utils/MapTransformer.py"
    click VQH "https://github.com/woodfrog/maptracker/blob/main/plugin/models/utils/query_update.py"
    click MDH "https://github.com/woodfrog/maptracker/blob/main/plugin/models/heads/MapDetectorHead.py"
    click MSH "https://github.com/woodfrog/maptracker/blob/main/plugin/models/heads/MapSegHead.py"
    click BD "https://github.com/woodfrog/maptracker/blob/main/plugin/datasets/base_dataset.py"
    click ND "https://github.com/woodfrog/maptracker/blob/main/plugin/datasets/nusc_dataset.py"
    click AD "https://github.com/woodfrog/maptracker/blob/main/plugin/datasets/argo_dataset.py"
    click VE "https://github.com/woodfrog/maptracker/blob/main/plugin/datasets/evaluation/vector_eval.py"
    click RE "https://github.com/woodfrog/maptracker/blob/main/plugin/datasets/evaluation/raster_eval.py"
    click DM "https://github.com/woodfrog/maptracker/blob/main/plugin/datasets/evaluation/distance.py"
    click AP "https://github.com/woodfrog/maptracker/blob/main/plugin/datasets/evaluation/AP.py"

    %% Styling
    classDef bev fill:#f9d,stroke:#333
    classDef vec fill:#adf,stroke:#333
    classDef memory fill:#9f9,stroke:#333
    classDef data fill:#ffa,stroke:#333
    classDef eval fill:#f99,stroke:#333
    classDef output fill:#99f,stroke:#333

    %% Legend
    subgraph Legend
        L1["BEV Components"]:::bev
        L2["Vector Components"]:::vec
        L3["Memory Components"]:::memory
        L4["Data Components"]:::data
        L5["Evaluation Components"]:::eval
        L6["Output Components"]:::output
    end
```
