# idkiro/dehazeformer architecture

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

- Interactive diagram: https://gitdiagram.com/idkiro/dehazeformer
- Repository: https://github.com/idkiro/dehazeformer

## Overview

##### Project type and purpose
- This is a research‐oriented deep learning codebase for single‐image dehazing using Vision Transformers (DehazeFormer).
- It provides end‐to‐end training, evaluation, and demo setups for different datasets (indoor, outdoor, RESIDE, RS‐Haze).

##### File structure
- Top‐level scripts:
- train.py – orchestrates the training loop (data loading → model → loss → optimizer → logging).
- test.py – runs evaluation/inference on a trained model.
- run.sh – convenience wrapper for common training/testing commands.
- configs/… – per‐dataset and per‐model JSON definitions of hyperparameters, paths, logging settings.
- datasets/loader.py – dataset abstraction layer that reads hazy/ground‐truth image pairs.
- models/dehazeformer.py – core Vision Transformer architecture and its variants (B, M, S, T).
- utils/ – supporting modules: common utilities (logging, checkpoint I/O), data_parallel wrapper for multi‐GPU training.
- save_models/ & data/ – expected runtime directory layout for model checkpoints and datasets (not in repo but described in README).
- requirements.txt, .gitignore, LICENSE, README.md – project metadata.

##### Extract additional insights from the README
- Core pipeline: load config → instantiate dataset and dataloader → build DehazeFormer variant → train with TensorBoard logging → save best checkpoints.
- Testing/inference loads a checkpoint, runs on test split, computes PSNR/SSIM.
- External services: Hugging Face demo for live inference, Google Drive/BaiduPan for downloading pretrained weights and datasets.

##### Diagramming conventions
- Components must be clearly labeled (e.g., “DehazeFormer Model”).
- Red or purple for external services (Google Drive, Hugging Face).
- Rectangles with rounded corners for code modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Storage Layer
    subgraph "Storage"
        DS[(Dataset Storage)]:::datastore
        CS[(Checkpoint Store)]:::datastore
    end

    %% Configuration and Metadata
    subgraph "Configuration & Metadata"
        CM["Config Manager"]:::utility
        RD["README.md"]:::meta
        RN["requirements.txt"]:::meta
        GI[".gitignore"]:::meta
        LI["LICENSE"]:::meta
    end

    %% Core Compute Modules
    subgraph "Core Pipeline"
        DL["Data Loader Module"]:::compute
        M["DehazeFormer Model"]:::compute
        TE["Training Engine"]:::compute
        EE["Evaluation Engine"]:::compute
    end

    %% Utilities
    subgraph "Utilities"
        CU["Common Utils"]:::utility
        DP["Data Parallel"]:::utility
        RS["Run Script (run.sh)"]:::utility
    end

    %% External Services
    HF(("Hugging Face Demo")):::external
    GD(("Google Drive / BaiduPan")):::external

    %% Monitoring
    TB["TensorBoard Logging"]:::compute

    %% Data and Control Flow
    GD -.-> DS
    GD -.-> CS

    CM -.->|loads configs| TE
    CM -.->|loads configs| DL

    DS -->|image batches| DL
    DL -->|features| M
    M -->|predictions| TE
    CU -->|utilities| TE
    DP -->|parallelism| TE
    TE -->|save checkpoints| CS
    TE -->|logs metrics| TB

    CS -->|load checkpoint| EE
    DS -->|image batches| DL
    DL -->|features| EE
    EE -->|evaluated outputs| HF

    RS -->|start training| TE
    RS -->|start evaluation| EE

    %% Click Events
    click CM "https://github.com/idkiro/dehazeformer/tree/main/configs/"
    click DL "https://github.com/idkiro/dehazeformer/blob/main/datasets/loader.py"
    click M "https://github.com/idkiro/dehazeformer/blob/main/models/dehazeformer.py"
    click TE "https://github.com/idkiro/dehazeformer/blob/main/train.py"
    click EE "https://github.com/idkiro/dehazeformer/blob/main/test.py"
    click RS "https://github.com/idkiro/dehazeformer/blob/main/run.sh"
    click CU "https://github.com/idkiro/dehazeformer/blob/main/utils/common.py"
    click DP "https://github.com/idkiro/dehazeformer/blob/main/utils/data_parallel.py"
    click RD "https://github.com/idkiro/dehazeformer/blob/main/README.md"
    click RN "https://github.com/idkiro/dehazeformer/blob/main/requirements.txt"
    click GI "https://github.com/idkiro/dehazeformer/blob/main/.gitignore"
    click LI "https://github.com/idkiro/dehazeformer/tree/main/LICENSE"

    %% Styles
    classDef datastore fill:#BBDEFB,stroke:#1E88E5,stroke-width:2px;
    classDef compute fill:#C8E6C9,stroke:#43A047,stroke-width:2px;
    classDef utility fill:#FFE0B2,stroke:#FB8C00,stroke-width:2px;
    classDef external fill:#E1BEE7,stroke:#8E24AA,stroke-width:2px;
    classDef meta fill:#E0E0E0,stroke:#9E9E9E,stroke-width:2px;
```
