# danishjeetsingh/denoising_diffusion_models architecture

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

- Interactive diagram: https://gitdiagram.com/danishjeetsingh/denoising_diffusion_models
- Repository: https://github.com/danishjeetsingh/denoising_diffusion_models

## Overview

Below are instructions tailored to this project:

##### Main Components
- Entry/Driver Scripts: The files ddpm.py and ddpm_conditonal.py are the main scripts that trigger the training/inference pipelines for unconditional and conditional diffusion models, respectively.
- Core Modules: modules.py likely defines key neural network components (such as the denoising network, UNet architecture, or other building blocks) while utils.py contains helper routines (e.g., data preprocessing, visualization, or model evaluation methods).
- Sample Outputs: The samples directory holds artifacts produced by the models (e.g., sample images, GIFs) which confirm the model’s behavior during training and inference.
- Environment and Configurations: The .gitignore and README provide context but no explicit build scripts are present, suggesting that configuration is handled through code parameters or command-line arguments.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Sources
    subgraph "Data Sources"
        DS1("Landscapes Dataset"):::dataset
        DS2("CIFAR-10 Dataset"):::dataset
    end

    %% Preprocessing
    Pre("Data Loader/Preprocessor (utils.py)"):::preprocess

    %% Unconditional Diffusion Pipeline
    subgraph "Unconditional Diffusion Pipeline"
        FNP("Forward Noising Process"):::process
        DN("Denoising Network (modules.py)"):::model
        TP("Training Phase"):::training
        EMA("EMA Module"):::optional
        SI("Sampling/Inference Engine (ddpm.py)"):::driver
    end

    %% Conditional Diffusion Pipeline
    subgraph "Conditional Diffusion Pipeline"
        CLI("Conditional Label Injector"):::process
        CFP("Forward Noising Process"):::process
        DN2("Denoising Network (modules.py)"):::model
        TP2("Training Phase"):::training
        CFG("Classifier-Free Guidance (CFG)"):::optional
        SI2("Sampling/Inference Engine (ddpm_conditonal.py)"):::driver
    end

    %% Outputs
    Out("Sample Outputs (samples directory)"):::output

    %% Environment / Configurations
    subgraph "Environment Configs"
        Env1("Config: .gitignore"):::config
        Env2("Config: README.md"):::config
    end

    %% Framework Information
    FT("PyTorch Framework"):::framework

    %% Data Flow Connections
    DS1 --> Pre
    DS2 --> Pre
    Pre --> FNP
    Pre --> CFP
    FNP --> DN
    CFP --> CLI
    CLI --> DN2
    DN --> TP
    DN2 --> TP2
    TP --> EMA
    EMA --> SI
    TP2 --> CFG
    CFG --> SI2
    SI --> Out
    SI2 --> Out

    %% Linking training phases to PyTorch framework (dotted connections)
    TP -.-> FT
    TP2 -.-> FT

    %% Legend (as a note node)
    L1["Legend:
◯ Dataset
▭ Code Module
◎ Process/Stage
☆ Optional Module
● Driver Script"]:::legend
    FT --- L1

    %% Click Events
    click Pre "https://github.com/danishjeetsingh/denoising_diffusion_models/blob/main/utils.py"
    click DN "https://github.com/danishjeetsingh/denoising_diffusion_models/blob/main/modules.py"
    click DN2 "https://github.com/danishjeetsingh/denoising_diffusion_models/blob/main/modules.py"
    click SI "https://github.com/danishjeetsingh/denoising_diffusion_models/blob/main/ddpm.py"
    click SI2 "https://github.com/danishjeetsingh/denoising_diffusion_models/blob/main/ddpm_conditonal.py"
    click Out "https://github.com/danishjeetsingh/denoising_diffusion_models/tree/main/samples"
    click Env1 "https://github.com/danishjeetsingh/denoising_diffusion_models/blob/main/.gitignore"
    click Env2 "https://github.com/danishjeetsingh/denoising_diffusion_models/blob/main/README.md"

%% Styles
classDef dataset fill:#cce5ff,stroke:#3399ff,stroke-width:2px;
classDef preprocess fill:#ffe0b2,stroke:#ff9800,stroke-width:2px;
classDef process fill:#dcedc8,stroke:#558b2f,stroke-width:2px;
classDef model fill:#ffcdd2,stroke:#d32f2f,stroke-width:2px;
classDef training fill:#f0f4c3,stroke:#9e9d24,stroke-width:2px;
classDef optional fill:#e1bee7,stroke:#8e24aa,stroke-width:2px;
classDef driver fill:#bbdefb,stroke:#1565c0,stroke-width:2px;
classDef output fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px;
classDef config fill:#d1c4e9,stroke:#512da8,stroke-width:2px;
classDef framework fill:#ffecb3,stroke:#f57f17,stroke-width:2px;
classDef legend fill:#eeeeee,stroke:#757575,stroke-width:1px;
```
