Skip to content

wojciechc1/MoreColors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MoreColors

CICode style: Black Linter: Ruff Mypy

This is a deep learning project for automatic colorization of grayscale images using GANs (Generative Adversarial Networks). The goal was to take a black-and-white image and predict a realistic colored version. The project was designed and trained entirely in Google Colab using limited GPU resources (T4).

Demo & Deployment

Live demo: https://morecolors.onrender.com/

This demo is deployed on Render using FastAPI and integrated with GitHub Actions for automatic CI/CD.
Each commit to the main branch triggers a new build and redeployment.

Note:
The demo runs on Render’s free tier, which provides only 512 MB RAM, CPU-only execution, and introduces a cold start delay after inactivity.
Because the colorization model (PyTorch + U-Net GAN) is relatively heavy, inference is limited to low-resolution images (~128×128) for stability, and the colorization process can take several seconds to complete.

Features:

  • Generator: U-Net style architecture that takes a grayscale image and outputs a colored image.
  • Discriminator: CNN-based network that judges whether a colored image is real or generated.
  • Flexible image sizes: The model can handle different input sizes without being restricted to a fixed resolution.
  • Training on small datasets: Optimized to learn from fewer images, but higher resolution (e.g., 128x128), instead of massive datasets like CIFAR-10.

Challenges and Solutions:

Color blobs / artifacts:

  • When training, generated images often had large, unrealistic color patches.
  • Experimented with different loss weights, normalization layers, and dropout in the discriminator to stabilize learning.

Unstable generator vs. discriminator:

  • Sometimes the discriminator would dominate, causing the generator to fail, or vice versa.
  • Implemented gradient clipping, careful learning rate scheduling, and experimented with label smoothing to balance the GAN training.

Normalization issues:

  • Tried BatchNorm, InstanceNorm, and GroupNorm.
  • Found BatchNorm worked better for stability in this setup, but GroupNorm allowed some flexibility for variable batch sizes.

Limited computational resources:

  • Training on a T4 GPU in Colab with batch size 16.
  • Had to carefully optimize memory usage, reduce image size when needed, and use gradient clipping and efficient DataLoader settings (num_workers, pin_memory).

Limitations

  • Trained on low-res (128×128) images -> show color patches on bigger images.
  • Dataset was general-purpose -> may struggle with niche or unusual images.
  • GPU & resources: trained on T4 in Colab, so results depend on hardware.

version 1:

1 2
example_image example_image

version 2:

1238x750px 640x423px 500x333px 500x750px
black_and_white black_and_white black_and_white black_and_white
colored_img colored_img colored_img colored_img

About

GAN for automatic colorization of grayscale images using a U-Net architecture.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors