# kkyuhun94/dalda architecture

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

- Interactive diagram: https://gitdiagram.com/kkyuhun94/dalda
- Repository: https://github.com/kkyuhun94/dalda

## Overview

##### Main Components

a) Core Processing Pipeline:
- LLM Component (for prompt generation)
- Diffusion Model Component (IP-Adapter)
- Adaptive Guidance Scaling Module
- Classifier Training System

b) Data Flow Components:
- Input Dataset Handlers (Caltech101, Flowers102, Pets)
- Prompt Management System
- Augmentation Pipeline
- Output Generation System

**┌─ Input Layer ─────────────────────┐**
- Original Images                 │
- Dataset Handlers               │
- ┘
- ↓
**┌─ Processing Layer ────────────────┐**
- ┌─ LLM Branch ─┐ ┌─ DM Branch ─┐ │
- Prompt Gen.  │ │ IP-Adapter  │ │
- ┘ └────────────┘  │
- ↓              ↓         │
- ┌─ Fusion Module ─┐          │
- Adaptive Scaling│          │
- ┘          │
- ┘
- ↓
**┌─ Output Layer ──────────────────┐**
- Augmented Images             │
- Classifier Training          │
- ┘

##### Detailed Component Breakdown

a) Dataset Handlers (from semantic_aug/datasets/):
- Connections to Caltech101, Flowers102, and Pets modules
- Few-shot dataset handling

b) Prompt Management (from prompt_for_LLM/):
- System prompts
- User prompts
- LLM integration

c) Augmentation Pipeline (from semantic_aug/augmentations/):
- DALDA implementation
- Generative augmentation process

d) Configuration System (from configs/):
- Different configuration options
- Adaptive vs Random scaling

##### Key Interactions to Highlight

- Data flow from input datasets through the augmentation pipeline
- Prompt generation and processing path
- Integration points between LLM and Diffusion Model
- Adaptive scaling mechanism
- Training data generation flow

##### Technical Details

- Python 3.10 environment
- External dependencies (IP-Adapter, diffusers, CLIP)
- Configuration management system
- Dataset preprocessing requirements

##### Implementation Notes

- Version information and dependency requirements

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input["Input Layer"]
        OriginalImages["Original Images"]
        DatasetHandlers["Dataset Handlers"]:::dataset
        Caltech["Caltech101"]:::dataset
        Flowers["Flowers102"]:::dataset
        Pets["Pets"]:::dataset
        FewShot["Few-shot Dataset"]:::dataset
    end

    subgraph Processing["Processing Layer"]
        subgraph LLMBranch["LLM Branch"]
            LLMComponent["LLM Component"]:::llm
            PromptManagement["Prompt Management"]:::llm
            SystemPrompts["System Prompts"]:::prompt
            UserPrompts["User Prompts"]:::prompt
        end

        subgraph DMBranch["DM Branch"]
            IPAdapter["IP-Adapter"]:::dm
            DiffusionProcess["Diffusion Process"]:::dm
        end

        subgraph Integration["Integration"]
            AdaptiveScaling["Adaptive Guidance Scaling"]:::integration
            DALDACore["DALDA Core"]:::integration
        end
    end

    subgraph Output["Output Layer"]
        AugmentedImages["Augmented Images"]
        ClassifierTraining["Classifier Training"]:::training
    end

    %% Connections
    DatasetHandlers --> Caltech & Flowers & Pets & FewShot
    OriginalImages --> DatasetHandlers
    
    DatasetHandlers --> LLMComponent
    LLMComponent --> PromptManagement
    PromptManagement --> SystemPrompts & UserPrompts
    SystemPrompts & UserPrompts --> DALDACore
    
    OriginalImages --> IPAdapter
    IPAdapter --> DiffusionProcess
    DiffusionProcess --> AdaptiveScaling
    
    DALDACore --> AdaptiveScaling
    AdaptiveScaling --> AugmentedImages
    AugmentedImages --> ClassifierTraining

    %% Click Events
    click LLMComponent "https://github.com/kkyuhun94/dalda/blob/main/generate_prompt_by_LLM.py"
    click PromptManagement "https://github.com/kkyuhun94/dalda/tree/main/prompt_for_LLM/"
    click Caltech "https://github.com/kkyuhun94/dalda/blob/main/semantic_aug/datasets/caltech101.py"
    click Flowers "https://github.com/kkyuhun94/dalda/blob/main/semantic_aug/datasets/flowers102.py"
    click Pets "https://github.com/kkyuhun94/dalda/blob/main/semantic_aug/datasets/pets.py"
    click FewShot "https://github.com/kkyuhun94/dalda/blob/main/semantic_aug/few_shot_dataset.py"
    click SystemPrompts "https://github.com/kkyuhun94/dalda/blob/main/prompt_for_LLM/llm_prompt_1_system_pets.txt"
    click UserPrompts "https://github.com/kkyuhun94/dalda/blob/main/prompt_for_LLM/llm_prompt_1_user_pets.txt"
    click DALDACore "https://github.com/kkyuhun94/dalda/blob/main/semantic_aug/augmentations/dalda.py"
    click AdaptiveScaling "https://github.com/kkyuhun94/dalda/blob/main/configs/cfg_dalda_pets_base_prompt_adaptive_scaling_clip.py"
    click ClassifierTraining "https://github.com/kkyuhun94/dalda/blob/main/train_classifier.py"

    %% Styles
    classDef dataset fill:#3498db,stroke:#2980b9,color:white
    classDef llm fill:#2ecc71,stroke:#27ae60,color:white
    classDef dm fill:#e67e22,stroke:#d35400,color:white
    classDef integration fill:#9b59b6,stroke:#8e44ad,color:white
    classDef prompt fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef training fill:#34495e,stroke:#2c3e50,color:white

    %% Legend
    subgraph Legend
        L1["Dataset Components"]:::dataset
        L2["LLM Components"]:::llm
        L3["Diffusion Components"]:::dm
        L4["Integration Components"]:::integration
        L5["Prompt Components"]:::prompt
        L6["Training Components"]:::training
    end
```
