# li-chongyi/zero-dce_extension architecture

> Architecture diagram of the GitHub repository li-chongyi/zero-dce_extension, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/li-chongyi/zero-dce_extension
- Repository: https://github.com/li-chongyi/zero-dce_extension

## Overview

##### Project Type and Purpose
- This project is a computer vision deep learning application focused on enhancing low-light images using the Zero-DCE++ network.
- It uses PyTorch as the primary deep learning framework along with supporting libraries (e.g., OpenCV for image processing).

##### File Structure
- Top-level files and folders include:
- README.md for overall project description and usage.
- Two main Python scripts: lowlight_test.py (for testing/enhancement) and lowlight_train.py (for training the model).
- The “Zero-DCE++” folder that includes key modules:
- model.py – holds the network architecture for image enhancement.
- dataloader.py – handles loading and processing of the training and test image data.
- Myloss.py – likely contains custom loss functions for training.
- The “data” folder is divided into train and test datasets.
- “snapshots_Zero_DCE++” folder holds pre-trained model weights (e.g., Epoch99.pth).

##### Key Components
a. Data Sources:
- Train Data and Test Data folders located under “data”.
- (When testing) a “result” folder is generated to store enhanced images.

b. Data Loader:
- The dataloader.py module that reads images from the file system.

c. Model (Zero-DCE++ Network):
- model.py which encapsulates the deep learning network for low-light enhancement.
- Myloss.py (if used during training) to calculate the training error.

d. Training Pipeline:
- lowlight_train.py reads training data via the dataloader, passes it through model.py, applies losses (Myloss.py), and, subsequently, updates model parameters.
- The training process saves snapshots (model weights) in the “snapshots_Zero_DCE++” folder.

e. Testing Pipeline:
- lowlight_test.py loads the pre-trained model (Epoch99.pth) from snapshots, processes images from “data/test_data”, enhances them, and writes the outputs into a new “result” folder inside the “data” folder.

f. External Dependencies:
- PyTorch for deep learning operations.
- torchvision (supporting image transformations).
- OpenCV for image input/output processing.
- CUDA for acceleration if available.

- A “Data Module” representing input images, divided into “Train Data” and “Test Data”.
- A “Data Loader” block (from dataloader.py) that fetches and pre-processes images.
- A “Model Module” block representing the Zero-DCE++ network (model.py) along with the “Loss Component” (Myloss.py).
- A “Testing/Inference Pipeline” block encompassing lowlight_test.py, which loads pre-trained weights and processes test images.

- Rectangles for core processing modules (Data Loader, Model, Training Pipeline).

d. Clearly label every component with its associated file or function:
- Also clearly show “lowlight_train.py” and “lowlight_test.py” as entry points for training and inference respectively.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Sources
    subgraph "Data Sources"
        TData(("Train Data"))
        TestData(("Test Data"))
    end

    %% Data Loader
    DataLoader["Data Loader (dataloader.py)"]

    TData -->|"feeds"| DataLoader
    TestData -->|"feeds"| DataLoader

    %% Model & Processing
    subgraph "Model & Processing"
        Model["Model Module (model.py)"]
        Loss["Loss Component (Myloss.py)"]
    end

    DataLoader -->|"preprocesses"| Model
    Model -->|"lossCalc"| Loss

    %% Training Pipeline
    subgraph "Training Pipeline"
        Train["Training (lowlight_train.py)"]
        Loss -->|"updates"| Train
        Train -->|"savesWeights"| Snap(("Snapshot Storage"))
    end

    %% Testing Pipeline
    subgraph "Testing Pipeline"
        Test["Testing (lowlight_test.py)"]
        Model -->|"usedBy"| Test
        Test -->|"outputs"| Result(("Result Folder"))
    end

    %% External Dependencies
    subgraph "External Dependencies"
        PT["PyTorch"]
        TV["torchvision"]
        CV["OpenCV"]
        CUDA["CUDA"]
    end

    PT -->|"framework"| Model
    TV -->|"transforms"| Model
    CV -->|"I/O"| DataLoader
    CUDA -->|"accelerates"| Model

    %% Click Events
    click TData "https://github.com/li-chongyi/zero-dce_extension/tree/main/Zero-DCE++/data/train_data"
    click TestData "https://github.com/li-chongyi/zero-dce_extension/tree/main/Zero-DCE++/data/test_data"
    click DataLoader "https://github.com/li-chongyi/zero-dce_extension/blob/main/Zero-DCE++/dataloader.py"
    click Model "https://github.com/li-chongyi/zero-dce_extension/blob/main/Zero-DCE++/model.py"
    click Loss "https://github.com/li-chongyi/zero-dce_extension/blob/main/Zero-DCE++/Myloss.py"
    click Train "https://github.com/li-chongyi/zero-dce_extension/blob/main/Zero-DCE++/lowlight_train.py"
    click Test "https://github.com/li-chongyi/zero-dce_extension/blob/main/Zero-DCE++/lowlight_test.py"
    click Snap "https://github.com/li-chongyi/zero-dce_extension/tree/main/Zero-DCE++/snapshots_Zero_DCE++"

    %% Styles
    classDef processing fill:#e3f2fd,stroke:#2196F3,stroke-width:2px;
    classDef storage fill:#fff9c4,stroke:#fbc02d,stroke-width:2px;
    classDef external fill:#c8e6c9,stroke:#388e3c,stroke-width:2px;

    class DataLoader,Model,Loss,Train,Test processing;
    class TData,TestData,Snap,Result storage;
    class PT,TV,CV,CUDA external
```
