PyTorch · U-Net · Computer Vision

Image Colorization with U-Net

A deep-learning colorization pipeline that learns to predict chrominance from grayscale landscape images in Lab color space and reconstructs the result back to RGB.

Model output

Drag to reveal the predicted color

Interactive
Colorized mountain and lake prediction
Grayscale mountain and lake input
GrayscalePredicted

Drag the divider to compare the grayscale input with the model’s predicted colorization.

Project details

How the colorization pipeline works

01

Dataset preparation

A custom landscape-image dataset is prepared as paired grayscale and color examples. Images are transformed into Lab color space so luminance can be separated from chrominance.

02

U-Net architecture

The encoder downsamples the image to capture context while the decoder restores spatial resolution. Skip connections preserve fine details between matching encoder and decoder stages.

03

Prediction target

The network outputs a two-channel tensor for the a and b chrominance components. A tanh activation constrains the prediction before the channels are combined with luminance.

04

Training and inference

Training uses MSELoss, Adam, a 10% validation split and automatic mixed precision. The trained state is saved as colorization_unet.pth and can be reloaded for inference.

Result gallery

More colorization results

Grid of grayscale and predicted colorized landscapesView full result image ↗