Skip to content

Keerthi421/Image-colourization

Repository files navigation

Black and White Image Colorization

This project uses deep learning to automatically colorize black and white images using a pre-trained caffe model.

Requirements

  • Python 3.x
  • OpenCV (cv2)
  • NumPy
  • Matplotlib

Setup

  1. Install the required packages:

    pip install -r requirements.txt
    
  2. Run the setup script that will create or download the required model files:

    python setup.py
    

    This script will:

    • Create the necessary directories
    • Generate the prototxt file locally
    • Create the pts_in_hull.npy file
    • Try to download the caffemodel file (about 130MB)

    If any of these steps fail, the script will provide manual instructions.

  3. Alternatively, you can manually set up the project by:

    • Running python create_prototxt.py to create the prototxt file
    • Running python create_pts_in_hull.py to create the pts_in_hull.npy file
    • Downloading the caffemodel file from here
  4. Place your black and white images in the input_images folder.

Usage

To colorize all images in the input_images folder:

python image_colorization.py

To colorize a single image:

python example.py input_images/your_image.jpg output_images/colorized.jpg

The colorized images will be saved in the output_images folder, and the program will also display the original and colorized images for comparison.

How It Works

This implementation uses a pre-trained deep learning model that:

  1. Converts the image to LAB color space
  2. Predicts the A and B color channels from the L (lightness) channel
  3. Combines the original L channel with the predicted A and B channels to produce the colorized image

Troubleshooting

If you encounter issues with the model files:

  1. Try running the individual scripts:
    • python create_prototxt.py
    • python create_pts_in_hull.py
  2. For the caffemodel file, you may need to manually download it and place it in the project directory.

Credits

Based on the project described in the TechVidvan tutorial and uses the model developed by:

  • Zhang, R., Isola, P., & Efros, A. A. (2016). Colorful Image Colorization. ECCV.

mkdir -p models images outputs

move colorization_deploy_v2.prototxt models/ move pts_in_hull.npy ./

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages