# weichen582/retinexnet architecture

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

- Interactive diagram: https://gitdiagram.com/weichen582/retinexnet
- Repository: https://github.com/weichen582/retinexnet

## Overview

RetinexNet is a TensorFlow low-light image enhancement application. Its main workflow accepts low-light images, decomposes them into reflectance and illumination, relights the illumination, and combines the results into enhanced images; optional decomposition outputs can also be saved. Training uses paired low-/high-light images in separate decomposition and relighting phases, with evaluation and checkpoints. The model excerpts are partial, so internal training details beyond the shown calls are kept high-level.

Main entry points: [`main.py`](https://github.com/weichen582/retinexnet/blob/master/main.py) (CLI Workflow), [`model.py`](https://github.com/weichen582/retinexnet/blob/master/model.py) (Enhancement Controller), [`utils.py`](https://github.com/weichen582/retinexnet/blob/master/utils.py) (Image I/O), [`data`](https://github.com/weichen582/retinexnet/tree/master/data) (Training Pairs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Application Workflow"]
  node_main["CLI Workflow<br/>[main.py]"]
  node_evaluation["Evaluation Samples<br/>[model.py]"]
  node_results["Saved Results"]
end

subgraph group_model["Enhancement Model"]
  node_enhancer["Enhancement Controller<br/>[model.py]"]
  node_decom["Retinex Decomposition<br/>[model.py]"]
  node_relight["Illumination Relighting<br/>[model.py]"]
  node_combine["Image Reconstruction<br/>[model.py]"]
  node_training["Phase Training<br/>[model.py]"]
end

subgraph group_data["Image Data"]
  node_train_data[("Training Pairs")]
  node_eval_data[("Evaluation Images")]
  node_test_data[("Test Images")]
  node_image_io["Image I/O<br/>[utils.py]"]
end

subgraph group_state["Model State"]
  node_checkpoint["Checkpoint Handling<br/>[model.py]"]
  node_decom_state[("Decomposition Weights")]
  node_relight_state[("Relighting Weights")]
end

node_user(("User"))

node_user -->|"chooses phase"| node_main
node_train_data -->|"training inputs"| node_main
node_eval_data -->|"evaluation inputs"| node_main
node_test_data -->|"test inputs"| node_main
node_main -->|"loads images"| node_image_io
node_main -->|"invokes training or test"| node_enhancer
node_main -->|"starts both phases"| node_training
node_main -->|"sets sample destination"| node_evaluation
node_main -->|"sets save destination"| node_results
node_enhancer -->|"builds decomposition"| node_decom
node_enhancer -->|"builds relighting"| node_relight
node_enhancer -->|"builds enhanced output"| node_combine
node_enhancer -->|"implements train"| node_training
node_enhancer -->|"loads and saves"| node_checkpoint
node_decom -->|"supplies reflectance and illumination"| node_relight
node_relight -->|"supplies relit illumination"| node_combine
node_decom -->|"supplies reflectance"| node_combine
node_training -->|"evaluates periodically"| node_evaluation
node_training -->|"saves phase weights"| node_checkpoint
node_checkpoint -->|"restores or saves"| node_decom_state
node_checkpoint -->|"restores or saves"| node_relight_state
node_enhancer -->|"writes result images"| node_image_io
node_image_io -->|"saves PNGs"| node_results

click node_train_data "https://github.com/weichen582/retinexnet/tree/master/data"
click node_eval_data "https://github.com/weichen582/retinexnet/tree/master/data/eval/low"
click node_test_data "https://github.com/weichen582/retinexnet/tree/master/data/test/low"
click node_main "https://github.com/weichen582/retinexnet/blob/master/main.py"
click node_image_io "https://github.com/weichen582/retinexnet/blob/master/utils.py"
click node_enhancer "https://github.com/weichen582/retinexnet/blob/master/model.py"
click node_decom "https://github.com/weichen582/retinexnet/blob/master/model.py"
click node_relight "https://github.com/weichen582/retinexnet/blob/master/model.py"
click node_combine "https://github.com/weichen582/retinexnet/blob/master/model.py"
click node_training "https://github.com/weichen582/retinexnet/blob/master/model.py"
click node_evaluation "https://github.com/weichen582/retinexnet/blob/master/model.py"
click node_checkpoint "https://github.com/weichen582/retinexnet/blob/master/model.py"
click node_decom_state "https://github.com/weichen582/retinexnet/tree/master/model/Decom"
click node_relight_state "https://github.com/weichen582/retinexnet/tree/master/model/Relight"

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_main,node_evaluation,node_results,node_user toneBlue
class node_enhancer,node_decom,node_relight,node_combine,node_training toneAmber
class node_train_data,node_eval_data,node_test_data,node_image_io toneMint
class node_checkpoint,node_decom_state,node_relight_state toneRose
```

## Components

### Application Workflow

- [CLI Workflow](https://github.com/weichen582/retinexnet/blob/master/main.py): `main.py`
- [Evaluation Samples](https://github.com/weichen582/retinexnet/blob/master/model.py): `model.py`
- **Saved Results**

### Enhancement Model

- [Enhancement Controller](https://github.com/weichen582/retinexnet/blob/master/model.py): `model.py`
- [Retinex Decomposition](https://github.com/weichen582/retinexnet/blob/master/model.py): `model.py`
- [Illumination Relighting](https://github.com/weichen582/retinexnet/blob/master/model.py): `model.py`
- [Image Reconstruction](https://github.com/weichen582/retinexnet/blob/master/model.py): `model.py`
- [Phase Training](https://github.com/weichen582/retinexnet/blob/master/model.py): `model.py`

### Image Data

- [Training Pairs](https://github.com/weichen582/retinexnet/tree/master/data): `data`
- [Evaluation Images](https://github.com/weichen582/retinexnet/tree/master/data/eval/low): `data/eval/low`
- [Test Images](https://github.com/weichen582/retinexnet/tree/master/data/test/low): `data/test/low`
- [Image I/O](https://github.com/weichen582/retinexnet/blob/master/utils.py): `utils.py`

### Model State

- [Checkpoint Handling](https://github.com/weichen582/retinexnet/blob/master/model.py): `model.py`
- [Decomposition Weights](https://github.com/weichen582/retinexnet/tree/master/model/Decom): `model/Decom`
- [Relighting Weights](https://github.com/weichen582/retinexnet/tree/master/model/Relight): `model/Relight`

### Other components

- **User**

## Connections

- User → CLI Workflow: chooses phase
- Training Pairs → CLI Workflow: training inputs
- Evaluation Images → CLI Workflow: evaluation inputs
- Test Images → CLI Workflow: test inputs
- CLI Workflow → Image I/O: loads images
- CLI Workflow → Enhancement Controller: invokes training or test
- CLI Workflow → Phase Training: starts both phases
- CLI Workflow → Evaluation Samples: sets sample destination
- CLI Workflow → Saved Results: sets save destination
- Enhancement Controller → Retinex Decomposition: builds decomposition
- Enhancement Controller → Illumination Relighting: builds relighting
- Enhancement Controller → Image Reconstruction: builds enhanced output
- Enhancement Controller → Phase Training: implements train
- Enhancement Controller → Checkpoint Handling: loads and saves
- Retinex Decomposition → Illumination Relighting: supplies reflectance and illumination
- Illumination Relighting → Image Reconstruction: supplies relit illumination
- Retinex Decomposition → Image Reconstruction: supplies reflectance
- Phase Training → Evaluation Samples: evaluates periodically
- Phase Training → Checkpoint Handling: saves phase weights
- Checkpoint Handling → Decomposition Weights: restores or saves
- Checkpoint Handling → Relighting Weights: restores or saves
- Enhancement Controller → Image I/O: writes result images
- Image I/O → Saved Results: saves PNGs
