# jmhb0/o2vae architecture

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

- Interactive diagram: https://gitdiagram.com/jmhb0/o2vae
- Repository: https://github.com/jmhb0/o2vae

## Overview

##### Main Components

a. Data Processing Layer:
- Input data handling (`data/datasets.py`)
- Data preprocessing components (`prealignment/`)
- Dataset-specific modules (O2MNIST and MEFS datasets)

b. Model Architecture:
- Core VAE implementation (`models/vae.py`)
- Encoder components:
- O2-invariant encoders (`models/encoders_o2/`)
- Vanilla encoders (`models/encoders_vanilla/`)
- Decoder components (`models/decoders/`)
- Registration module (`registration/`)

c. Training Infrastructure:
- Training loops (`train_loops.py`)
- Configuration management (`configs/`)
- Logging and monitoring (Weights & Biases integration)

d. Utility Layer:
- Evaluation utilities (`utils/eval_utils.py`)
- Plotting utilities (`utils/plotting_utils.py`)
- Cluster utilities (`utils/cluster_utils.py`)

**[Input Data] → [Preprocessing] → [Model Architecture] → [Output Representations]**
- ↑
- [Training Infrastructure]
- ↑
- [Configuration & Utils]

##### Key Relationships to Highlight

a. Data Flow:
- How data moves from raw input through preprocessing to the model
- VAE's encoder-decoder architecture
- Demonstrate how the registration module interfaces with the training process

b. Training Flow:
- Configuration management flow
- Training loop interaction with model components
- Logging and monitoring pathways

##### External Dependencies
- PyTorch integration
- e2cnn library connection
- Weights & Biases logging

##### Deployment Components
- Model saving/loading paths
- Pretrained model handling
- Example notebook integration

- Any special symbols used for O2-invariance features
- Configuration options and their impacts

This design should emphasize the project's unique focus on orientation-invariant representation learning while maintaining clarity about the overall system architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Data_Layer
        Input[Raw Input Data]
        DataProc[Data Processing]:::data
        PreAlign[Prealignment]:::data
        Datasets["Dataset Modules"]:::data
        MEFS["MEFS Dataset"]:::data
        O2MNIST["O2MNIST Dataset"]:::data
    end

    subgraph Model_Architecture
        VAE[Core VAE]:::model
        subgraph Encoders
            O2Enc[O2-Invariant Encoder]:::model
            VanEnc[Vanilla Encoder]:::model
        end
        Dec[Decoder]:::model
        Reg[Registration Module]:::model
    end

    subgraph Training_Infrastructure
        Train[Training Loops]:::train
        Config[Configuration Management]:::train
        WandB[Weights & Biases]:::external
    end

    subgraph Utils
        EvalUtil[Evaluation Utils]:::util
        PlotUtil[Plotting Utils]:::util
        ClusterUtil[Cluster Utils]:::util
    end

    subgraph Deployment
        PreTrained[Pretrained Models]:::deploy
        Examples[Example Notebooks]:::deploy
    end

    %% Data Flow
    Input --> DataProc
    DataProc --> PreAlign
    PreAlign --> |Optional| VAE
    DataProc --> Datasets
    Datasets --> MEFS
    Datasets --> O2MNIST
    MEFS --> VAE
    O2MNIST --> VAE

    %% Model Architecture Flow
    VAE --> O2Enc
    VAE --> VanEnc
    O2Enc --> Dec
    VanEnc --> Dec
    Reg --> VAE

    %% Training Flow
    Config --> Train
    Train --> VAE
    Train --> WandB
    WandB --> PreTrained

    %% Utils Integration
    EvalUtil --> Train
    PlotUtil --> Train
    ClusterUtil --> Train

    %% Deployment Flow
    VAE --> PreTrained
    PreTrained --> Examples

    %% Styling
    classDef data fill:#3498db
    classDef model fill:#2ecc71
    classDef train fill:#e67e22
    classDef util fill:#95a5a6
    classDef external fill:#9b59b6
    classDef deploy fill:#34495e

    %% Click Events
    click DataProc "https://github.com/jmhb0/o2vae/blob/master/data/datasets.py"
    click PreAlign "https://github.com/jmhb0/o2vae/blob/master/prealignment/prealignment.py"
    click VAE "https://github.com/jmhb0/o2vae/blob/master/models/vae.py"
    click O2Enc "https://github.com/jmhb0/o2vae/blob/master/models/encoders_o2/e2scnn.py"
    click VanEnc "https://github.com/jmhb0/o2vae/blob/master/models/encoders_vanilla/cnn_encoder.py"
    click Dec "https://github.com/jmhb0/o2vae/blob/master/models/decoders/cnn_decoder.py"
    click Reg "https://github.com/jmhb0/o2vae/blob/master/registration/registration.py"
    click Train "https://github.com/jmhb0/o2vae/blob/master/train_loops.py"
    click Config "https://github.com/jmhb0/o2vae/tree/master/configs/"
    click MEFS "https://github.com/jmhb0/o2vae/tree/master/data/mefs/"
    click O2MNIST "https://github.com/jmhb0/o2vae/tree/master/data/o2_mnist/"
    click EvalUtil "https://github.com/jmhb0/o2vae/blob/master/utils/eval_utils.py"
    click PlotUtil "https://github.com/jmhb0/o2vae/blob/master/utils/plotting_utils.py"
    click ClusterUtil "https://github.com/jmhb0/o2vae/blob/master/utils/cluster_utils.py"
    click PreTrained "https://github.com/jmhb0/o2vae/tree/master/wandb/pretrained_models/"
    click Examples "https://github.com/jmhb0/o2vae/tree/master/examples/"
```
