Skip to main content

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.

architecture

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.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for resenh 0.1.1
File Size Uploaded Provenance Actions
resenh-0.1.1.tar.gz 34.5 kB Without provenance Details for resenh-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for resenh 0.1.1
File Interpreter ABI Platform Actions
resenh-0.1.1-py3-none-any.whl Python 3 none any Details for resenh-0.1.1-py3-none-any.whl

Total release size: 76.2 kB

Release files / resenh-0.1.1.tar.gz

Download URL resenh-0.1.1.tar.gz
Size 34.5 kB
Tags Source
SHA-256 checksum
How to use checksums
79461c8edff59ca669a3240722c80e743824f90b8a4b9ab6b25ab872380d4217
BLAKE2b-256 checksum
How to use checksums
9161b3a5286b81b4d1f93e4d21d17984b2a102f3fc6e32471b202fd3e81871f9
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.1-py3-none-any.whl

Download URL resenh-0.1.1-py3-none-any.whl
Size 41.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
91127582badd67747c57aa96f6edb1ceac2a07ffe5428b699f4d8e147c38a891
BLAKE2b-256 checksum
How to use checksums
e391120448f3d14458fbf5b8e9d04ba13f37aa4e136b5c5d344f9247753f20c9
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.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page