resenh: robust low-light image restoration and enhancement
resenh brightens dark, noisy, colour-shifted photos without blowing out lamps, amplifying
noise or inventing colours. It combines three things:
- A classical branch: illumination estimation, Retinex, CLAHE, edge-preserving denoising and colour correction, with every parameter adapted per image.
- A deep network: Retinexformer (ICCV 2023) fine-tuned with the GT-mean loss, taking the classical results as extra inputs.
- A quality controller: checks every candidate output for over-exposure, colour shift, detail loss and noise amplification, and fuses them.
Live demo (runs in your browser): https://resenh.sharadh.blog
Install
pip install "resenh[dl]" # classical + deep hybrid (PyTorch)
pip install resenh # classical only (numpy + OpenCV, no PyTorch)
pip install "resenh[app]" # + Gradio web app
pip install "resenh[eval]" # + LPIPS / NIQE metrics
From source: git clone https://github.com/SharadhNaidu/resen && cd resen && pip install -e ".[dl,app,eval,dev]".
Weights are downloaded and checksum-verified on first use (cached in ~/.cache/resenh).
Use
import resenh
res = resenh.enhance("night.jpg") # adaptive hybrid (default)
resenh.save_image(res.image, "night_enhanced.png")
res.intermediates["illumination"] # every stage is inspectable
res.decision # controller weights and guard scores
res.stats, res.params # analyzer measurements → chosen parameters
resenh.enhance("night.jpg", mode="classical") # no deep learning
resenh.enhance("night.jpg", mode="dl") # network only
resenh enhance night.jpg -o out.png --save-intermediates stages/
resenh bench --device cpu # latency at ~1 MP
resenh app # web UI at http://localhost:7860
One command with Docker: docker build -t resenh . && docker run -p 7860:7860 resenh
Results
Full tables with all metrics and 95% bootstrap CIs are in
eval_P1_T01.md. The ablation is in docs/ablation.md
and the failure analysis in docs/failures.md.
Protocol.
- Plain RGB PSNR. No GT-mean correction and no test-time brightness knobs.
- Checkpoints are fixed in advance (
docs/devlog/protocol-decision.md); none is selected on the test set. - Train and test on the same benchmark only. The LOL-v1/v2 overlap is documented.
- Our harness reproduces the official Retinexformer checkpoints exactly: 25.15 / 22.79 / 25.67 dB, matching the published audit.
Reproduce
pip install -e ".[train,dev]"
python -m kaggle datasets download -d ohmahler91/lolv1-and-lolv2 -p data/raw/lol --unzip
python -m kaggle datasets download -d bjzh123/lsrw123 -p data/raw/lsrw --unzip
python -m kaggle datasets download -d mijancse12/onedrive-1-6-13-2026 -p data/raw/unpaired --unzip
python training/data_prep.py # verify counts, scene-grouped val splits, dedup
# official Retinexformer weights → weights/retinexformer/ (see src/resenh/models/weights.py)
bash training/queue.sh # fine-tune per benchmark + ablations
python eval/run_eval.py --methods classical "dl:retinexformer-{bench}" ...
python eval/make_report.py # writes eval_P1_T01.md, docs/ablation.md
pytest
Project layout
| Path | What |
|---|---|
src/resenh/ |
the package: io, analysis, classical/, models/, controller, pipeline, metrics, viz, cli, app |
training/ |
data preparation, training script and GPU queue |
eval/ |
evaluation harness and report generator |
docs/ |
design document, architecture diagram, ablation, failure analysis, development log |
app/ |
Space entry point and example images |
Credits
- Retinexformer: Cai et al., ICCV 2023 (MIT), repo.
- GT-mean loss: Liao et al., ICCV 2025.
- LIME: Guo et al., TIP 2017.
- Guided filter: He et al., TPAMI 2013.
- Evaluation audit: "What Does LOL Measure?", arXiv 2610.38121.
- Datasets: LOL (Wei et al. 2018), LOL-v2 (Yang et al. 2021), LSRW (Hai et al. 2023), DICM, LIME, MEF, NPE and VV.
Limitations and responsible use
See the design document §8. In short, enhanced images can contain hallucinated detail and must not be used as forensic evidence. The training data is small and mostly indoor.
License
MIT
Metadata
Release files for resenh 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| resenh-0.1.0.tar.gz | 29.6 kB | Without provenance | Details for resenh-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| resenh-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for resenh-0.1.0-py3-none-any.whl |
Total release size: 66.5 kB
Release files / resenh-0.1.0.tar.gz
| Download URL | resenh-0.1.0.tar.gz |
|---|---|
| Size | 29.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e2b32ee745275d3e661352c58c57a308f88f07aba7d9c5df63d71ffccac2a48c
|
|
BLAKE2b-256 checksum How to use checksums |
afb7ecbad9cc388f9500b4d98c91830cf039534aa4a5c2b4720568a441b80ec5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Release files / resenh-0.1.0-py3-none-any.whl
| Download URL | resenh-0.1.0-py3-none-any.whl |
|---|---|
| Size | 36.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2d869ba83291832e5bedbbc188763c9c5a0232942d6e06d87fcaa7c715da9111
|
|
BLAKE2b-256 checksum How to use checksums |
8b42701ca8dd385756b1c73652991c87948be8668ef7afd92b056fee4e3554e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Security for resenh 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.