# johnscotttt/low_light_image_enhancement architecture

> Architecture diagram of the GitHub repository johnscotttt/low_light_image_enhancement, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/johnscotttt/low_light_image_enhancement
- Repository: https://github.com/johnscotttt/low_light_image_enhancement

## Overview

This repository implements paired low-light image enhancement: prepare low/normal image lists, train the enhancement model, then run inference and optionally save enhanced images while reporting quality metrics. Training combines a detail network with a wavelet-conditioned diffusion network and optimizes them with component losses; evaluation uses the configured dataset and a supplied checkpoint. The README documents LOL/LOLv2 datalist generation and callable train/eval entry points. Some runner and model wiring is only partially sampled, so uncertain internal connections are omitted.

Main entry points: [`modules/runner.py`](https://github.com/johnscotttt/low_light_image_enhancement/blob/single/modules/runner.py) (Train and eval), [`modules/model.py`](https://github.com/johnscotttt/low_light_image_enhancement/blob/single/modules/model.py) (Enhancement model), [`modules/ddm.py`](https://github.com/johnscotttt/low_light_image_enhancement/blob/single/modules/ddm.py) (Diffusion network), [`utils/preprocessing.py`](https://github.com/johnscotttt/low_light_image_enhancement/blob/single/utils/preprocessing.py) (Datalist generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_preprocessing["Datalist generation<br/>[preprocessing.py]"]
  node_tsv["Pair TSV"]
  node_loader["Paired data loader<br/>[dataloader.py]"]
end

subgraph group_workflow["Training and evaluation"]
  node_config["Default config<br/>[default.toml]"]
  node_entry["Train entry<br/>[train.py]"]
  node_runner["Train and eval<br/>[runner.py]"]
  node_checkpoint["Model weights"]
  node_images["Enhanced images"]
end

subgraph group_network["Enhancement network"]
  node_model["Enhancement model<br/>[model.py]"]
  node_detail["Detail network<br/>[detail.py]"]
  node_diffusion["Diffusion network<br/>[ddm.py]"]
  node_unet["Diffusion U-Net<br/>[diffusion.py]"]
  node_wavelet["Wavelet transforms<br/>[wavelet.py]"]
end

subgraph group_quality["Loss and quality"]
  node_loss["Training losses<br/>[loss.py]"]
  node_metrics["Image metrics<br/>[metrics.py]"]
  node_lpips["LPIPS metric"]
end

node_user(("Researcher"))
node_dataset["Paired images"]

node_user -->|"requests lists"| node_preprocessing
node_dataset -->|"reads pairs"| node_preprocessing
node_preprocessing -->|"writes lists"| node_tsv
node_user -->|"starts training"| node_entry
node_entry -->|"calls train"| node_runner
node_user -->|"calls eval"| node_runner
node_config -->|"configures runs"| node_runner
node_tsv -->|"provides pairs"| node_loader
node_runner -->|"loads batches"| node_loader
node_runner -->|"constructs and runs"| node_model
node_model -->|"uses detail branch"| node_detail
node_model -->|"uses diffusion branch"| node_diffusion
node_diffusion -->|"denoises"| node_unet
node_diffusion -->|"transforms bands"| node_wavelet
node_runner -->|"computes training loss"| node_loss
node_runner -->|"scores predictions"| node_metrics
node_runner -->|"saves or loads"| node_checkpoint
node_runner -->|"saves enhanced output"| node_images
node_runner -.->|"computes LPIPS"| node_lpips

click node_preprocessing "https://github.com/johnscotttt/low_light_image_enhancement/blob/single/utils/preprocessing.py"
click node_config "https://github.com/johnscotttt/low_light_image_enhancement/blob/single/cfg/default.toml"
click node_entry "https://github.com/johnscotttt/low_light_image_enhancement/blob/single/train.py"
click node_runner "https://github.com/johnscotttt/low_light_image_enhancement/blob/single/modules/runner.py"
click node_loader "https://github.com/johnscotttt/low_light_image_enhancement/blob/single/modules/dataloader.py"
click node_model "https://github.com/johnscotttt/low_light_image_enhancement/blob/single/modules/model.py"
click node_detail "https://github.com/johnscotttt/low_light_image_enhancement/blob/single/modules/detail.py"
click node_diffusion "https://github.com/johnscotttt/low_light_image_enhancement/blob/single/modules/ddm.py"
click node_unet "https://github.com/johnscotttt/low_light_image_enhancement/blob/single/modules/diffusion.py"
click node_wavelet "https://github.com/johnscotttt/low_light_image_enhancement/blob/single/modules/wavelet.py"
click node_loss "https://github.com/johnscotttt/low_light_image_enhancement/blob/single/modules/loss.py"
click node_metrics "https://github.com/johnscotttt/low_light_image_enhancement/blob/single/utils/metrics.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_preprocessing,node_tsv,node_loader toneBlue
class node_config,node_entry,node_runner,node_checkpoint,node_images toneAmber
class node_model,node_detail,node_diffusion,node_unet,node_wavelet toneMint
class node_loss,node_metrics,node_lpips toneRose
class node_user,node_dataset toneIndigo
```

## Components

### Data preparation

- [Datalist generation](https://github.com/johnscotttt/low_light_image_enhancement/blob/single/utils/preprocessing.py): `utils/preprocessing.py`
- **Pair TSV**
- [Paired data loader](https://github.com/johnscotttt/low_light_image_enhancement/blob/single/modules/dataloader.py): `modules/dataloader.py`

### Training and evaluation

- [Default config](https://github.com/johnscotttt/low_light_image_enhancement/blob/single/cfg/default.toml): `cfg/default.toml`
- [Train entry](https://github.com/johnscotttt/low_light_image_enhancement/blob/single/train.py): `train.py`
- [Train and eval](https://github.com/johnscotttt/low_light_image_enhancement/blob/single/modules/runner.py): `modules/runner.py`
- **Model weights**
- **Enhanced images**

### Enhancement network

- [Enhancement model](https://github.com/johnscotttt/low_light_image_enhancement/blob/single/modules/model.py): `modules/model.py`
- [Detail network](https://github.com/johnscotttt/low_light_image_enhancement/blob/single/modules/detail.py): `modules/detail.py`
- [Diffusion network](https://github.com/johnscotttt/low_light_image_enhancement/blob/single/modules/ddm.py): `modules/ddm.py`
- [Diffusion U-Net](https://github.com/johnscotttt/low_light_image_enhancement/blob/single/modules/diffusion.py): `modules/diffusion.py`
- [Wavelet transforms](https://github.com/johnscotttt/low_light_image_enhancement/blob/single/modules/wavelet.py): `modules/wavelet.py`

### Loss and quality

- [Training losses](https://github.com/johnscotttt/low_light_image_enhancement/blob/single/modules/loss.py): `modules/loss.py`
- [Image metrics](https://github.com/johnscotttt/low_light_image_enhancement/blob/single/utils/metrics.py): `utils/metrics.py`
- **LPIPS metric**

### Other components

- **Researcher**
- **Paired images**

## Connections

- Researcher → Datalist generation: requests lists
- Paired images → Datalist generation: reads pairs
- Datalist generation → Pair TSV: writes lists
- Researcher → Train entry: starts training
- Train entry → Train and eval: calls train
- Researcher → Train and eval: calls eval
- Default config → Train and eval: configures runs
- Pair TSV → Paired data loader: provides pairs
- Train and eval → Paired data loader: loads batches
- Train and eval → Enhancement model: constructs and runs
- Enhancement model → Detail network: uses detail branch
- Enhancement model → Diffusion network: uses diffusion branch
- Diffusion network → Diffusion U-Net: denoises
- Diffusion network → Wavelet transforms: transforms bands
- Train and eval → Training losses: computes training loss
- Train and eval → Image metrics: scores predictions
- Train and eval → Model weights: saves or loads
- Train and eval → Enhanced images: saves enhanced output
- Train and eval → LPIPS metric: computes LPIPS
