Original Images
Black and White
Model Predictions
This project implements the Pix2Pix paper to create a model that converts black and white images to color. It's based on the research paper "Image-to-Image Translation with Conditional Adversarial Networks" by Phillip Isola, Jun-Yan Zhu, Tinghui Zhou, and Alexei A. Efros.
- Overview
- Requirements
- Installation
- Usage
- Training
- Model Architecture
- Results
- Contributing
- License
- Acknowledgements
This implementation uses a conditional Generative Adversarial Network (cGAN) to learn a mapping from input black and white images to output colorized images. The model is trained on paired data, where each pair consists of a black and white image and its corresponding color version.
- Python 3.7+
- PyTorch 1.7+
- torchvision
- numpy
- Pillow
- tqdm
-
Clone this repository:
git clone https://github.com/ivanrj7j/Pix2Pix-Image-Colorizer.git cd Pix2Pix-Image-Colorizer -
Install the required packages:
pip install -r requirements.txt -
Download the model from the releases and paste it into your project
To colorize a black and white image:
>>> from main import colorizeImage
>>> colorizeImage("path/to/image", True, "path/to/output/")The generator follows a U-Net-like architecture with skip connections:
- Initial downsampling layer
- 6 downsampling blocks
- Bottleneck layer
- 7 upsampling blocks with skip connections
- Final layer to produce the colorized image
Each downsampling block consists of:
- Convolutional layer
- Batch normalization
- LeakyReLU activation
Each upsampling block consists of:
- Transposed convolutional layer
- Batch normalization
- ReLU activation
- Dropout (in the first 3 blocks)
The discriminator follows a PatchGAN architecture:
- Initial convolutional layer with LeakyReLU
- 3 discriminator blocks
- Final convolutional layer
Each discriminator block consists of:
- Convolutional layer
- Batch normalization
- LeakyReLU activation
These results demonstrate the effectiveness of our Pix2Pix implementation in converting black and white images to color. While the generated images may not always perfectly match the original colors, they provide a plausible and visually appealing colorization.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Pix2Pix paper by Phillip Isola, Jun-Yan Zhu, Tinghui Zhou, and Alexei A. Efros
- PyTorch team for their excellent deep learning framework
- Machine Learning Collection by Aladdin Persson, specifically the ML/Pytorch/GANs section, which provided valuable insights and implementation details
- Aladdin Persson's YouTube channel for educational content on machine learning and deep learning techniques