# yjb6/igs architecture

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

- Interactive diagram: https://gitdiagram.com/yjb6/igs
- Repository: https://github.com/yjb6/igs

## Overview

##### Project type and purpose
- This is a research-oriented, Python-based computer vision package for dynamic scene reconstruction via “Instant Gaussian Stream.” It provides two primary pipelines:
- Streaming reconstruction (initial Gaussian training with RaDe-GS, compression, per-frame streaming inference)
- AGM-Net training (learning to refine Gaussian streams)
- It is not a web or full-stack app, but rather a modular ML system leveraging PyTorch, custom CUDA rasterizers, and external submodules.

##### Top-level structure and architectural choices
- Top-level directories:
- igs/        → core library: data loaders, model definitions, utilities
- configs/    → YAML configurations for demo, training, evaluation
- acc_cfg/    → accelerate config for distributed training
- submodules/ → external code (RaDe-GS and its CUDA rasterizers, tetra triangulation, etc.)
- script/     → data-preparation and helper scripts (subsampling, pairing, video conversion)
- lpipsPyTorch/ → perceptual metric module
- infer_batch.py & main.py → CLI entry points for inference and training
- Architecture pattern:
- Modular python package (igs) separating data, models, and utils
- Config-driven execution (YAML files consumed by main.py and infer_batch.py)
- External submodules integrated as pip-installable packages (CUDA rasterizers, torch_cluster)

##### Core components and interactions
A. Data Ingestion & Preparation
- Raw multi-view images + Colmap outputs → script/pre_test_data.sh, subsample.py → structured on disk
- build_3dgs_dataset.py for large-scale dataset construction
B. Configuration
- configs/*.yaml define model hyperparameters, data paths, training/eval settings
- acc_cfg/default_config.yaml controls distributed setup
C. Core Library (igs/)
- igs.data: Data loaders (data.py, infer_data.py), utilities for batching and preprocessing
- igs.models:
– gaussian_model.py & grid_encoder.py: Core Gaussian Splatting data structures
– networks.py, transformers.py, unet.py: Neural refinement architectures (AGM-Net)
– unimatch/: Transformer-based matching submodule for temporal coherence
- igs.utils: Config parsing, image/graphics utils, loss computation, I/O and system utilities
D. Execution Entry Points
- main.py → launches training of AGM-Net via accelerate
- infer_batch.py → streaming inference on key-candidate sequences, renders per-frame outputs
E. External Libraries & Submodules
- RaDe-GS (submodules/RaDe-GS): Initial Gaussian training & compression pipelines
- diff-gaussian-rasterization(::clamp) CUDA rasterizers for splatting
- tetra_triangulation: Auxiliary C++ triangulation Python bindings
- lpipsPyTorch: Perceptual loss metric
- torch_cluster, PyTorch 2.0+, torchvision, torchaudio

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Legend omitted for brevity

    %% Data Storage
    RawData(("Raw Data")):::storage
    OrganizedData(("Organized Dataset")):::storage
    OutputStorage(("Output Storage")):::storage

    %% Data Preparation Scripts
    subgraph "Data Prep Scripts" 
        direction TB
        PreTest["pre_test_data.sh"]:::script
        Subsample["subsample.py"]:::script
        GenPair["generate_test_pair.ipynb"]:::script
    end

    %% Configuration Files
    subgraph "Configurations" 
        direction TB
        TrainYAML[[train.yaml]]:::config
        DemoYAML[[demo.yaml]]:::config
        EvalBeef[[eval_beef.yaml]]:::config
        EvalSear[[eval_sear.yaml]]:::config
        EvalTrim[[eval_trim.yaml]]:::config
        EvalVR[[eval_vr.yaml]]:::config
        BBoxJSON[[bbox.json]]:::config
        AccelYAML[[default_config.yaml]]:::config
    end

    %% CLI Entry Points
    subgraph "CLI Entry Points"
        direction TB
        TrainCLI(["main.py"]):::entry
        InferCLI(["infer_batch.py"]):::entry
    end

    %% Core Library
    subgraph "Core Library (igs)" 
        direction TB
        subgraph "igs.data"
            direction TB
            DataLoader["data.py"]:::core
            InferData["infer_data.py"]:::core
            DataUtils["utils.py"]:::core
        end
        subgraph "igs.models"
            direction TB
            GaussianModel["gaussian_model.py"]:::core
            GridEncoder["grid_encoder.py"]:::core
            GS["gs.py"]:::core
            Networks["networks.py"]:::core
            Transformers["transformers.py"]:::core
            UNet["unet.py"]:::core
            UniMatch["unimatch/"]:::core
        end
        subgraph "igs.utils"
            direction TB
            ConfigUtil["config.py"]:::core
            GraphicsUtil["graphics_utils.py"]:::core
            LossUtil["loss_utils.py"]:::core
            SysUtil["system_utils.py"]:::core
            GenUtil["general_utils.py"]:::core
            MiscUtil["misc.py"]:::core
            SaveUtil["saving.py"]:::core
            OpsUtil["ops.py"]:::core
            SHUtil["sh_utils.py"]:::core
            BaseUtil["base.py"]:::core
        end
    end

    %% External Submodules
    subgraph "External Submodules"
        direction TB
        RaDeGS["RaDe-GS"]:::external
        LPIPS["lpipsPyTorch"]:::external
        CUDA["diff-gaussian-rasterization"]:::external
        Triang["tetra_triangulation"]:::external
    end

    %% Relationships
    RawData --> PreTest
    RawData --> Subsample
    RawData --> GenPair
    PreTest --> OrganizedData
    Subsample --> OrganizedData
    GenPair --> OrganizedData

    OrganizedData --> DataLoader
    OrganizedData --> InferData

    TrainYAML --> TrainCLI
    DemoYAML --> InferCLI
    EvalBeef --> InferCLI
    EvalSear --> InferCLI
    EvalTrim --> InferCLI
    EvalVR --> InferCLI
    BBoxJSON --> InferCLI
    AccelYAML --> TrainCLI

    TrainCLI --> DataLoader
    InferCLI --> InferData

    DataLoader --> GaussianModel
    DataUtils --> GaussianModel
    InferData --> GS

    GaussianModel --> RaDeGS
    GS --> CUDA
    GS --> Triang

    GaussianModel --> GridEncoder
    Networks --> UNet
    Transformers --> Networks
    UniMatch --> Transformers

    GaussianModel --> LPIPS
    Networks --> LPIPS

    RaDeGS --> OutputStorage
    CUDA --> OutputStorage
    Triang --> OutputStorage

    OutputStorage --> VideoNB["video.ipynb"]:::script

    %% Click Events
    click PreTest "https://github.com/yjb6/igs/blob/master/script/pre_test_data.sh"
    click Subsample "https://github.com/yjb6/igs/blob/master/script/subsample.py"
    click GenPair "https://github.com/yjb6/igs/blob/master/script/generate_test_pair.ipynb"
    click VideoNB "https://github.com/yjb6/igs/blob/master/script/video.ipynb"
    click TrainYAML "https://github.com/yjb6/igs/blob/master/configs/train.yaml"
    click DemoYAML "https://github.com/yjb6/igs/blob/master/configs/demo.yaml"
    click EvalBeef "https://github.com/yjb6/igs/blob/master/configs/eval_beef.yaml"
    click EvalSear "https://github.com/yjb6/igs/blob/master/configs/eval_sear.yaml"
    click EvalTrim "https://github.com/yjb6/igs/blob/master/configs/eval_trim.yaml"
    click EvalVR "https://github.com/yjb6/igs/blob/master/configs/eval_vr.yaml"
    click BBoxJSON "https://github.com/yjb6/igs/blob/master/configs/bbox.json"
    click AccelYAML "https://github.com/yjb6/igs/blob/master/acc_cfg/default_config.yaml"
    click DataLoader "https://github.com/yjb6/igs/blob/master/igs/data/data.py"
    click InferData "https://github.com/yjb6/igs/blob/master/igs/data/infer_data.py"
    click DataUtils "https://github.com/yjb6/igs/blob/master/igs/data/utils.py"
    click GaussianModel "https://github.com/yjb6/igs/blob/master/igs/models/gaussian_model.py"
    click GridEncoder "https://github.com/yjb6/igs/blob/master/igs/models/grid_encoder.py"
    click GS "https://github.com/yjb6/igs/blob/master/igs/models/gs.py"
    click Networks "https://github.com/yjb6/igs/blob/master/igs/models/networks.py"
    click Transformers "https://github.com/yjb6/igs/blob/master/igs/models/transformers.py"
    click UNet "https://github.com/yjb6/igs/blob/master/igs/models/unet.py"
    click UniMatch "https://github.com/yjb6/igs/tree/master/igs/models/unimatch/"
    click ConfigUtil "https://github.com/yjb6/igs/blob/master/igs/utils/config.py"
    click GraphicsUtil "https://github.com/yjb6/igs/blob/master/igs/utils/graphics_utils.py"
    click LossUtil "https://github.com/yjb6/igs/blob/master/igs/utils/loss_utils.py"
    click SysUtil "https://github.com/yjb6/igs/blob/master/igs/utils/system_utils.py"
    click GenUtil "https://github.com/yjb6/igs/blob/master/igs/utils/general_utils.py"
    click MiscUtil "https://github.com/yjb6/igs/blob/master/igs/utils/misc.py"
    click SaveUtil "https://github.com/yjb6/igs/blob/master/igs/utils/saving.py"
    click OpsUtil "https://github.com/yjb6/igs/blob/master/igs/utils/ops.py"
    click SHUtil "https://github.com/yjb6/igs/blob/master/igs/utils/sh_utils.py"
    click BaseUtil "https://github.com/yjb6/igs/blob/master/igs/utils/base.py"
    click RaDeGS "https://github.com/yjb6/igs/tree/master/submodules/RaDe-GS/"
    click LPIPS "https://github.com/yjb6/igs/blob/master/lpipsPyTorch/modules/lpips.py"
    click CUDA "https://github.com/yjb6/igs/tree/master/submodules/RaDe-GS/submodules/diff-gaussian-rasterization-clamp/"
    click Triang "https://github.com/yjb6/igs/tree/master/submodules/RaDe-GS/submodules/tetra_triangulation/"
    click TrainCLI "https://github.com/yjb6/igs/blob/master/main.py"
    click InferCLI "https://github.com/yjb6/igs/blob/master/infer_batch.py"

    %% Styles
    classDef storage fill:#cccccc,stroke:#333,stroke-width:1px
    classDef script fill:#a2d5ab,stroke:#333,stroke-width:1px
    classDef config fill:#f9e79f,stroke:#333,stroke-width:1px
    classDef entry fill:#d7bde2,stroke:#333,stroke-width:1px
    classDef core fill:#aed6f1,stroke:#333,stroke-width:1px
    classDef external fill:#f5b7b1,stroke:#333,stroke-width:1px
```
