Darkroom restores and colorizes old black-and-white photographs. It removes noise and scratches, repairs faded contrast, and adds realistic color using deep learning.
Live demo: https://huggingface.co/spaces/Nussshra/Darkroom
Darkroom combines image colorization with old-photo restoration.
For colorization I use two models: a pretrained "Colorful Image Colorization" model (Zhang et al., 2016) as a baseline, and a U-Net with a ResNet18 encoder that I fine-tuned on my own set of images. For restoration I built a classical pipeline that denoises, removes scratches, and repairs contrast before the image is colorized.
The whole thing runs as an interactive web app built with Gradio and deployed on Hugging Face Spaces.
Colorization is done in the Lab color space, which separates lightness (L) from color (a, b). The grayscale image is the L channel; the model predicts a and b, and the three channels are recombined into a color image.
The fine-tuned model uses a ResNet18 encoder pretrained on ImageNet, with a decoder trained to predict the color channels from lightness. Training is self-supervised, it only needs color images, since the color channels are the target and the grayscale is the input.
For old photos, the restoration pipeline cleans the image before colorization: denoising with Non-local Means, scratch removal with morphological detection and inpainting, and contrast repair with a histogram stretch (or CLAHE).
To evaluate restoration objectively, I take clean color images, synthetically age them (fade, blur, noise, scratches), and measure how well the pipeline recovers the original. Across 50 test images:
| Method | PSNR | SSIM |
|---|---|---|
| Colorize only | 15.28 | 0.282 |
| Restore + colorize | 16.84 | 0.487 |
Restoring before colorizing improved SSIM by 0.205 and PSNR by 1.56 dB.
Colorization comparison (grayscale input, pretrained, fine-tuned, original):
Restoration stages (input, denoised, descratched, contrast, colorized):
git clone https://github.com/Nussshra/Darkroom.git
cd Darkroom
pip install -r requirements.txt
python download_models.py # downloads the pretrained colorizer weightsColorize an image:
python colorize_cli.py photo.jpg --compareRestore and colorize an old photo (also saves a stage-by-stage montage):
python restore_and_colorize.py old_photo.jpgRun the web app locally:
pip install -r deploy/requirements.txt
python deploy/app.pyThe fine-tuned model can be trained on any folder of color images (no labels required):
pip install -r requirements-train.txt
python train.py --data ./images --epochs 20 --batch-size 16 --size 256
python infer_finetuned.py photo.jpgA ready-to-run Colab notebook is included as finetune_colab.ipynb.
python evaluate_restoration.py --data ./test_imagesThis prints the PSNR/SSIM comparison and writes evaluation_results.csv. Add
--checkpoint checkpoints/colorization_finetuned.pth to evaluate the fine-tuned
model.
.
βββ colorizer.py # pretrained colorizer (OpenCV DNN)
βββ colorize_cli.py # command-line colorizer
βββ download_models.py # downloads the pretrained weights
βββ dataset.py # dataset for fine-tuning
βββ model.py # ResNet18-encoder U-Net
βββ train.py # training loop
βββ infer_finetuned.py # inference with the fine-tuned model
βββ restore.py # restoration pipeline
βββ degrade.py # synthetic aging for evaluation
βββ evaluate_restoration.py # PSNR/SSIM benchmark
βββ restore_and_colorize.py # end-to-end CLI
βββ deploy/ # Hugging Face Space (Gradio app)
βββ requirements.txt
βββ README.md
- Colorful Image Colorization β Richard Zhang, Phillip Isola, Alexei A. Efros (ECCV 2016), used as the pretrained baseline.
- The OpenCV DNN colorization sample.
- ResNet and ImageNet pretrained weights via torchvision.
Released under the MIT License (see LICENSE). The pretrained Zhang et al. model
carries its own license terms.


