# satoshi-kosugi/pg-ia-nilut architecture

> Architecture diagram of the GitHub repository satoshi-kosugi/pg-ia-nilut, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/satoshi-kosugi/pg-ia-nilut
- Repository: https://github.com/satoshi-kosugi/pg-ia-nilut

## Overview

##### Main Components
- Core Model & Lookup Tables: Represented by the “adaint” directory, especially the model implementation (model.py) and prompt guidance loss, as well as the “ailut_transform” extension that implements the neural implicit lookup tables (with C++/CUDA code in “csrc”).
- Dataset and Preprocessing: Include the “dataset.py”, “transforms.py”, and annotation files (in “annfiles”). This component handles dataset ingestion (FiveK and PPR10K) and data augmentation.
- Configuration & Training Scripts: Show the configuration files under “configs”, and training/testing routines in “tools” (e.g., tools/train.py, tools/test.py) that drive the experiments.
- MMEditing Toolbox: Represented by the “mmedit” directory. This is an external toolbox modified to support CLIP-based evaluation (CLIP-IQA integration) and provides additional model architectures, common layers, optimizers, schedulers, dataset handling pipelines, etc.
- Pretrained Models & Demo: The “pretrained” directory and demo scripts (demo.py in “adaint” and tools/demo.py) should be highlighted since they play a role in both inference and visualization.
- External Dependencies: Indicate that compiled extensions are built via setup scripts (setup.py in “ailut_transform” and setup_demo.py), and that the project relies on specific versions of PyTorch, CUDA, mmcv, and other libraries.

##### Architectural Patterns and Design Principles
- Modularity: Emphasize the separation between the core “adaint” functionality and the externally extended “mmedit” toolbox. Each major folder represents a separate layer or module.
- High-performance Extensions: Indicate that “ailut_transform” includes compiled code (with separate branches for CPU and CUDA implementations) that plug-in into the higher-level architecture.

##### Relevant Technologies, Frameworks, and Libraries
- Python 3.7.11, PyTorch 1.11.0 for deep learning.
- CUDA 11.3 for GPU acceleration.
- mmcv and MMEditing libraries as key dependencies.
- CLIP-based methods integrated within the MMEditing extensions for image quality assessment.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Loader & Preprocessing Subgraph
    subgraph "Data Loader & Preprocessing"
        DL_Dataset["Dataset Loader"]:::dataset
        DL_Transforms["Transforms"]:::dataset
        DL_Annotations["Annotations Files"]:::dataset
    end

    %% Core Model & IA-NILUT Subgraph
    subgraph "Core Model & IA-NILUT"
        Core["Core Model"]:::core
        AILUT["CPU/CUDA Extensions"]:::core
        Build["Build Scripts"]:::aux
    end

    %% MMEditing Toolbox Subgraph
    subgraph "MMEditing Toolbox"
        MMEdit["MMEditing Toolbox"]:::external
    end

    %% Training & Evaluation Pipeline Subgraph
    subgraph "Training & Evaluation Pipeline"
        Config["Configuration Files"]:::train
        Train["Training Script"]:::train
        Test["Testing Script"]:::train
    end

    %% Pretrained Models & Demo Subgraph
    subgraph "Pretrained Models & Demo"
        Pretrained["Pretrained Models"]:::demo
        Demo_Adaint["Demo Script (adaint)"]:::demo
        Demo_Tools["Demo Script (tools)"]:::demo
    end

    %% Data Flow and Relationships
    DL_Dataset -->|"raw_data"| Train
    DL_Transforms -->|"augmented_data"| Train
    DL_Annotations -->|"annotations"| Train

    Config -->|"configs"| Train
    Train -->|"trains"| Core
    Train -->|"uses"| AILUT
    Train -->|"integrates"| MMEdit
    MMEdit -->|"CLIP-IQA calls"| Core
    Train -->|"evaluation"| Test
    Test -->|"loads"| Pretrained
    Pretrained -->|"inference"| Demo_Adaint
    Pretrained -->|"visualization"| Demo_Tools
    Pretrained -.->|"feedback"| Config

    Core -->|"builds with"| Build
    AILUT -->|"compiled_by"| Build

    %% Click Events
    click DL_Dataset "https://github.com/satoshi-kosugi/pg-ia-nilut/blob/main/adaint/dataset.py"
    click DL_Transforms "https://github.com/satoshi-kosugi/pg-ia-nilut/blob/main/adaint/transforms.py"
    click DL_Annotations "https://github.com/satoshi-kosugi/pg-ia-nilut/tree/main/adaint/annfiles"
    click Core "https://github.com/satoshi-kosugi/pg-ia-nilut/blob/main/adaint/model.py"
    click AILUT "https://github.com/satoshi-kosugi/pg-ia-nilut/tree/main/adaint/ailut_transform"
    click Build "https://github.com/satoshi-kosugi/pg-ia-nilut/blob/main/adaint/ailut_transform/setup.py"
    click Config "https://github.com/satoshi-kosugi/pg-ia-nilut/tree/main/adaint/configs"
    click Train "https://github.com/satoshi-kosugi/pg-ia-nilut/blob/main/tools/train.py"
    click Test "https://github.com/satoshi-kosugi/pg-ia-nilut/blob/main/tools/test.py"
    click MMEdit "https://github.com/satoshi-kosugi/pg-ia-nilut/tree/main/mmedit"
    click Pretrained "https://github.com/satoshi-kosugi/pg-ia-nilut/tree/main/pretrained"
    click Demo_Adaint "https://github.com/satoshi-kosugi/pg-ia-nilut/blob/main/adaint/demo.py"
    click Demo_Tools "https://github.com/satoshi-kosugi/pg-ia-nilut/blob/main/tools/demo.py"

    %% Styles
    classDef dataset fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef core fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef external fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef train fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef demo fill:#D2B4DE,stroke:#7D3C98,stroke-width:2px;
    classDef aux fill:#FAD7A0,stroke:#D68910,stroke-width:2px;
```
