Download README.md from Kiriti-Ray/luma-restore: direct link, hf CLI and curl.
- Browser
- Download file 7.5 kB
-
https://huggingface.co/Kiriti-Ray/luma-restore/resolve/main/README.md
- Command line
-
hf download hf://Kiriti-Ray/luma-restore/README.md
-
curl -L -o README.md https://huggingface.co/Kiriti-Ray/luma-restore/resolve/main/README.md
license: mit
pipeline_tag: image-to-image
library_name: pytorch
tags:
- low-light-image-enhancement
- image-restoration
- adaptive-inference
- safetensors
LumaRestore
Can a compact low-light enhancer use fewer restoration passes on images that have already stabilized? LumaRestore is a trainable RGB image restoration model with one shared update block and up to three passes. The 18,677-parameter model and a 17,595-parameter CNN control were trained from scratch on a MacBook Pro with an Apple M5 Max.
Results on 100 official test pairs
| Method | PSNR ↑ (dB) | SSIM ↑ | Mean passes | Median latency (ms) ↓ |
|---|---|---|---|---|
| Low-light input | 9.72 | 0.199 | 0.00 | — |
| Validation-tuned gamma | 17.56 | 0.624 | 0.00 | 0.18 |
| Single-pass CNN | 17.88 | 0.689 | 1.00 | 0.62 |
| Shared block · one pass | 18.40 | 0.664 | 1.00 | 1.21 |
| Shared block · two passes | 17.26 | 0.642 | 2.00 | 1.62 |
| Shared block · three passes | 17.53 | 0.643 | 3.00 | 2.04 |
| Regional adaptive exit | 18.35 | 0.663 | 1.02 | 1.71 |
| Whole-image adaptive exit | 18.29 | 0.662 | 1.05 | 1.67 |
- One fixed pass had the highest PSNR at 18.40 dB. Additional passes reduced mean PSNR on this test split. The single-pass CNN reached the highest SSIM at 0.689 and the lowest learned-model latency at 0.62 ms.
- Regional early exit averaged 1.02 passes. It stopped after one pass on 98 images and after two on 2. It improved on fixed three-pass PSNR by 0.82 dB (95% paired bootstrap interval +0.64 to +1.00 dB). A fixed one-pass call was faster and slightly better on average.
- The regional and whole-image policies scored similarly. The paired PSNR difference was +0.06 dB (95% interval −0.07 to +0.18 dB). The selected validation thresholds were 0.295 regional and 0.265 whole-image, with a tuned gamma exponent of 0.250.
Per-image results, calibration curves, and split manifests · Iterative training history · CNN training history · Training configuration
Architecture
LumaRestore starts with a square-root exposure lift and carries two state variables across stages: a spatial log-gain map and an additive RGB detail residual. A small convolutional block operates at half resolution and predicts three updates. A smoothed gain map changes exposure, an RGB residual changes detail, and a learned gate limits the detail update in shadows using a local luminance prior. The same weights are reused at every stage. Model implementation
The early-exit policy measures output change in a 4 × 4 grid. It uses the largest mean absolute RGB change in any cell, so a small active region can keep refinement going. For comparison, a second policy measures whole-image mean change. Both use the same trained weights, leave early only when their statistic is below a threshold, and are calibrated separately under the same validation budget.
The project takes inspiration from the iterative separation of illumination and content in GRUN by Rihan Zhang, Fengyang Xiao, Yuhan Chen, Chunming He, and Sina Farsiu. Here the changes are a shared lightweight update block, an explicit shadow gate, and a validation-calibrated regional exit rule. Adaptive restoration and low-light early exit have prior work. This release evaluates this particular combination. GRUN · Restore, Assess, Repeat · Adaptive Low Light Enhancement
Evaluation protocol
The dataset is LOL-v2 Real, introduced by Wenhan Yang, Haofeng Huang, Wenjing Wang, Shiqi Wang, and Jiaying Liu. We use the pinned mirror revision documented in the code. Of the 689 original training pairs, the first 609 filenames form the training set and the last 80 form the validation set. The 100 official test pairs are evaluated at their native 600 × 400 resolution. The split is by filename, so scene independence within the original training split has not been established. Dataset authors · Pinned mirror
Both networks train from random initialization with the same aligned 128 × 128 crops, seed, AdamW schedule, and image loss. The one-pass CNN learns a residual over the same exposure initialization. The iterative model receives deep supervision at all three exits with loss weights 0.20, 0.30, and 0.50. The checkpoint uses best mean validation PSNR at a 224-pixel long side. The gamma exponent and halt thresholds use full-resolution validation pairs. The thresholds minimize average stage count subject to a 0.15 dB validation PSNR budget relative to three fixed stages.
PSNR uses RGB in [0, 1]. SSIM uses an 11 × 11 Gaussian window and averages over valid windows and RGB channels. Evaluation averages per-image scores and applies no target-dependent exposure correction. Inference medians use batch size one, warmed-up Metal execution, and synchronization before and after the model call. They exclude loading, data transfer, and metric computation. Bootstrap intervals resample test images and represent evaluation variation for these weights.
Run inference
Python 3.11+ is required. Install the project in a virtual environment and pass an RGB image to the CLI.
python -m venv .venv
. .venv/bin/activate
python -m pip install -e .
python -m luma_restore.infer --checkpoint checkpoints/iterative --stages 1 input.jpg output.png
The default runs all three stages. Use --stages 1 or --stages 2 for a fixed shorter run; use --threshold 0.295 --exit-stat regional to reproduce the regional policy. The CLI accepts --device cpu, mps, or cuda. Safetensors inference preserves image dimensions.
Reproduce
python -m luma_restore.data data/lolv2-real
python -m luma_restore.train data/lolv2-real runs/reproduce --device auto \
--epochs 16 --batch-size 20 --crop 128 --repeats 2 --seed 42
python -m luma_restore.evaluate data/lolv2-real runs/reproduce reports/reproduced.json --device auto
python -m unittest discover -s tests -v
To benchmark the released weights directly, pass checkpoints in place of runs/reproduce to the evaluation command.
Scope
This is a one-seed experiment on LOL-v2 Real. It does not establish robustness to other cameras, RAW inputs, or degradations beyond low light. Small output changes can signal a stable but incorrect result. The adaptive policies introduce a host synchronization after each check, so stage savings and wall-clock savings need separate measurement. The CNN and iterative variants differ in computation and structure, so their comparison measures the whole design. The fixed and adaptive exits use identical iterative weights.
Dataset images are obtained separately from the pinned mirror. The benchmark figure can be rebuilt with python -m pip install -e '.[report]' and python reports/render_figures.py. The code and checkpoints are released under the MIT license.
