MakeItColor: Image Colorization Model
Overview
MakeItColor is a deep learning model designed for automatic image colorization. It transforms grayscale images into vivid, realistic colorized outputs using a PyTorch-based Convolutional Neural Network (CNN) architecture integrated with the ModelScope framework.
This model builds upon the work of DDColor, utilizing a dual-encoder approach and trained on the ImageNet-Val5k dataset.
Features
- Task: Image Colorization
- Framework: PyTorch, ModelScope
- Architecture: Convolutional Neural Network (CNN)
- Input: Grayscale images (single-channel)
- Output: Colorized images (RGB format)
Installation
Ensure you have Python 3.7+ installed. Then, install the required dependencies:
pip install opencv-python
pip install modelscope==1.12.0
pip install datasets==2.14.7
pip install pillow
pip install numpy
Usage
ModelScope Pipeline
import cv2
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
from huggingface_hub import snapshot_download
# Download the model files to a local directory
snapshot_download(repo_id="muhammadnoman76/makeitcolor", local_dir="./makeitcolor", repo_type="model")
# Initialize the colorization pipeline
img_colorization = pipeline(Tasks.image_colorization, model='./makeitcolor')
# Load a grayscale image
img_path = 'input.jpg'
# Run colorization
result = img_colorization(img_path)
# Save the colorized image
cv2.imwrite('result.png', result['output_img'])
Note:
- Ensure that the input image (
input.jpg
) is a proper grayscale (single-channel) image.- The output (
result.png
) will be a standard RGB image.
Google Colab
For an interactive demonstration, try our Google Colab notebook.
Model Files
The repository contains:
pytorch_model.pt
: Pre-trained model weightsconfiguration.json
: Model configuration file for ModelScope integrationREADME.md
: Documentation
Requirements
Hardware
- CPU (supported)
- GPU (recommended for faster inference)
Software Dependencies
modelscope
opencv-python
torch
Input Format
- Grayscale images (
.png
,.jpg
, etc.)
Example Workflow
- Prepare a grayscale image (e.g.,
input.jpg
) - Run the provided example code
- Check the output file (
result.png
) for the colorized result
Limitations
- May struggle with highly complex, ambiguous, or abstract grayscale images
- Performance and output quality depend on the clarity and details of the input
- Primarily optimized for natural images; results may vary for synthetic or artistic inputs
Credits
This work builds upon and was inspired by the DDColor project.
MakeItColor leverages a dual-encoder strategy from DDColor and is trained on the ImageNet-Val5k dataset.
Special thanks to the creators of DDColor for their foundational contributions.
License
This project is licensed under the Apache License 2.0.
Contact
For issues, questions, or feedback:
- Open an issue on the Hugging Face repository
- Contact the maintainer directly at: [email protected]
Developed by Muhammad Noman