4 2final
4 2final
Image Colorization
Submitted to
K L DEEMED TO BE UNIVERSITY
(Off Campus, Hyderabad)
(In partial fulfilment of the requirements for the award of the degree)
BACHELOR OF TECHNOLOGY
in
By
Venkatesh K (2010030359)
DEPARTMENT OF
COMPUTER SCIENCE AND ENGINEERING
K L DEEMED TO BE UNIVERSITY
AZIZNAGAR, MOINABAD , HYDERABAD-500 075
MARCH 2024
CERTIFICATE
This is to certify that the project titled Image Colorization is being submitted by
Venkatesh K (2010030359)
in partial fulfillment of the requirements for the award of the degree of Bachelor of
ance and supervision. The results embodied in this project have not been submitted to
any other University or Institute for the award of any degree or diploma.
i
ABSTRACT
ii
ACKNOWLEDGEMENT
First and foremost, I offer my sincere gratitude to my internal guide DR. RAJIB
supported me throughout this project with her/his patience and valuable suggestions.
I would like to express my gratitude to DR. ARPITA GUPTA, Head of the Department of
Computer Science and Engineering for his support and valuable suggestions during the
project work.
I am also grateful to the Principal DR. A. RAMAKRISHNA for providing me with all the
resources in the college to make my project a success. I thank him for his valuable
project. I would also like to thank all the supporting staff of the Dept. of CSE and all
other departments who have been helpful directly or indirectly in making the project
a success.
Venkatesh K (2010030359)
Akhil Reddy M (2010030513)
v
TABLE OF CONTENTS
ABSTRACT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
ACKNOWLEDGEMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii
TABLE OF CONTENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iv
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Background of the Project . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 Scope of the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Literature Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3 Proposed System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.1 Tools and Technologies used . . . . . . . . . . . . . . . . . . . . . . . 10
4.2 Models and their descriptions . . . . . . . . . . . . . . . . . . . . . . 10
iv
5 Results and Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
6.3.2 Achievements: . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6.4 Recommendations for future work . . . . . . . . . . . . . . . . . . . . 18
6.4.1 Model Refinement: . . . . . . . . . . . . . . . . . . . . . . . . 18
v
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Appendices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
A Source code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
B Screen shots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
vi
Chapter 1
Introduction
Through the use of deep learning algorithms, our research unlocks creative expression
and improves data visualization by smoothly transforming written descriptions into vi-
sually appealing visuals. Bridging the Text-Image Gap: Textual information and visual
content are significantly different in today’s big data and digital communication world.
Images capture the subtleties, emotions, and details of the real world, whereas text com-
municates ideas, stories, and concepts.
Overcoming this divide has enormous potential for a range of uses, including data vi-
sualization and creative expression.For a considerable amount of time, creative profes-
sionals such as designers and artists have been looking for ways to convert their abstract
ideas, textual stories, or imaginative concepts into tangible visual forms. Text-to-image
generation opens up new channels for artistic expression by making it simple to visual-
ize concepts.
The ability to transform textual data or insights into visual representations is extremely
valuable in the fields of data science and analytics. Text-to-image generation makes
complex data easier to understand and more interesting for a wider audience.The gen-
eration of text from images is crucial for human-computer interaction. It gives users
the ability to interact with machines using natural language and get visual responses.
This has ramifications for interactive applications, chatbots, and virtual assistants where
users can express their needs or questions verbally and receive corresponding visual
outputs.
1
1.2 Problem Statement
Photographs are our personal story, a timeline of our lives filled with faces and places
that we love. They are our story, which we can then share with others. Colorization
of grayscale images has become a more researched area in recent years, thanks to the
advent of deep convolutional neural networks. We attempt to apply this concept to
colorization of black and white images.
1.3 Objectives
• The main objective of this project is to convert black and white images to color
images.
objective.
• To revitalize and preserve historical black and white images by adding color,
providing a more immersive and realistic viewing experience.
• To enhance the visual appeal and interpretability of black and white images by
adding color, making it easier for viewers to discern details and understand the
content.
• To augment training datasets for computer vision tasks, such as object detection,
image classification, and segmentation, by artificially creating color versions of
black and white images.
• To provide artists and photographers with tools for creative expression, allowing
them to experiment with different color schemes and styles in their artwork.
• To make visual content more accessible to individuals with color vision deficien-
cies by adding color cues to black and white images, aiding in better comprehen-
sion and interpretation.
2
1.4 Scope of the Project
The project encompasses the implementation and utilization of pre-trained deep learn-
ing models for image colorization, inspired by the groundbreaking research outlined
in the ”Colorful Image Colorization” (ECCV 2016) and ”Deep Colorization” (SIG-
GRAPH 2017) papers. It offers a comprehensive command-line interface (CLI) built
using the argparse library, facilitating user interaction by allowing specification of in-
put parameters such as the path to the grayscale image, preference for GPU accel-
eration, and naming conventions for output files. Through efficient GPU utilization,
the project enhances computational performance, particularly beneficial for processing
dard resolution (256x256), ensuring compatibility with the colorization models. Upon
colorization, the project visualizes the results using the matplotlib library, displaying
the original grayscale image alongside the input grayscale image and the colorized out-
puts from both ECCV 2016 and SIGGRAPH 2017 models, enabling easy comparison
and evaluation.
Additionally, the project facilitates seamless organization and management of colorized
images by saving them as separate files with user-defined prefixes. Through clear docu-
mentation and usage guidelines, the project aims to empower users of varying expertise
levels in deep learning and image processing to explore and apply cutting-edge tech-
3
Chapter 2
Literature Review
This is the data from the literature survey we have done by collecting some research
papers.
This paper proposes a new color image coding scheme called “colorization im-
age coding.” The scheme is based on the colorization technique which can colorize
a monochrome image by giving a small number of color pixels. They develop algo-
rithms useful for color image coding. It is shown that the new colorization technique
is effective to image coding, especially for high compression rate, through the experi-
ments using different types of images. This paper divides automatic coloring methods
into three types: image coloring based on prior knowledge, image coloring based on
reference pictures, and interactive coloring. The coloring method can meet the needs
of most users, but there are disadvantages such as users cannot get the multiple objects
in a picture of different reference graph coloring. Aiming at this problem, based on
the instance of color image segmentation and image fusion technology, the use of deep
learning is proposed to implement regional mixed color more and master the method.
They implemented four different Deep Learning models for automatic colorization of
grayscale images, two based on CNN and two based on GAN. They have shown that a
simple CNN model outperforms large and complex Inceptionresnetv2 based model on
a small dataset. It was easily able to produce plausible colors for the high-level com-
ponents in images like sky, mountains and forests but did not focus on smaller details.
We propose a new framework for automatic colorization of gray scale images by using
4
the composition of features from multiple color images to solve for the most likely col-
oring with machine learning. The intention of this process is to alleviate the amount of
manual labor required to colorize a photograph.
Advantages:
• Historical Restoration
• Artistic Expression
• Personilization
Limitations:
• Subjectivity
• Accuracy Challenges
5
Table 2.1:
Year Of
Title Author Name Advantages Disadvantages
Publish
1. Limited model
1.Comprehensive
selection
Image Colorization with CLI Interface
Jeff Hwang, November 2. Performance
Deep Convolutional 2. GPU Acceleration
You Zhou 2019 variability
Neural Networks 3.Visualization with
3. Potential for
matplotlib
overfitting
1. Automation
1. Dataset Dependency
Automatic Image Abhishek Pandey, 2. Deep Learning
Mar 2. Computational
Colorization using Rohit Sahay, Techniques
2020 Complexity
Deep Learning C. Jayavarthini 3. Realism and
3. Interpretability
Accuracy
1. Generelization
Image Colorization using 2. Comparative 1. Complexity
January
Generative Adversarial Kamyar Nazeri Analysis 2. Data Dependency
2021
Networks 3. Training on Public 3. Training Stability
Datasets
1. Lack of Specificity in
1. New Taxonomy of
Evaluation Metrics
Colorization Networks
Saeed Anwar, January 2. Potential Bias in
Image Colorization 2. New Benchmark
Muhammad Tahir 2022 Dataset Creation
Dataset
3. Focus on Deep
3. Systematic Evaluation
Learning Approaches
6
Chapter 3
Proposed System
We have implemented this project using three models. First model is Convolutional
Neural Networks model with learned deep priors architecture. Second model Convolu-
7
tional Neural Networks model with VGG-16 architecture. And the last model is using
OpenCV. In the Convolutional Neural Networks model with learned deep priors archi-
tecture and Convolutional Neural Networks each layer acts as the sub model of the
model, which improvises the output. The first model Convolutional Neural Networks
model with learned deep priors architecture gives the better results compared to other
models.
Step-1
Step-3
Now implement using OpenCV and Caffe Model.
Step-4:
d. Using the lightness values colorize the black and white image.
Step-5:
Now we will implement Convolutional Neural Networks model with learned deep priors
8
3.2 System Requirements
Hardware :
• 4GB Ram
• i3 or i5 Processor
• Graphic Driver
Software :
• Skimage
• Virtual Environment
• Python
9
Chapter 4
Implementation
• Matplotlib
• PyTorch
• argparse
The ”CNN with learned deep priors” architecture integrates learned priors into
statistical regularities and guiding the learning process towards more meaningful
representations.
tions for hierarchical feature extraction from input data. They excel in processing
visual data such as images due to their ability to capture spatial hierarchies of
features.
10
Learned Priors:
Learned priors are derived from data during the training process, representing
underlying patterns or structures present in the data. They act as regularization
to create a diverse array of visualizations, both static and interactive. It’s highly
favored among data scientists, researchers, and engineers for its extensive suite of
features, including support for various plot types like line plots, scatter plots, and
Moreover, its compatibility across platforms and integration with libraries like
NumPy and Pandas make it accessible and user-friendly. With multiple backends
for exporting plots and extensive customization options, Matplotlib empowers
dle errors, and create complex CLIs with sub-commands. Argparse integrates
seamlessly with help messages, ensuring user-friendly documentation. Overall,
argparse is a flexible and standardized tool in the Python ecosystem for building
command-line interfaces.
11
Chapter 5
• Image Quality
• Inference Speed
• Scalability
• Hardware Dependency
The code may have dependencies on specific hardware configurations for optimal
performance, especially when leveraging GPU acceleration.
Users with limited access to GPU resources may experience slower inference
speeds or degraded performance compared to users with high-end hardware.
12
5.3 Limitations and future scope
Limitations:
• Hardware Dependency
Future Scope:
13
Chapter 6
The project focuses on implementing image colorization using deep learning tech-
niques, specifically utilizing pre-trained models from the ECCV 2016 and SIGGRAPH
2017 papers. The code provides a command-line interface (CLI) for users to specify
input parameters such as the image path, GPU usage preference, and output file names.
It preprocesses input images, extracts the luminance (L) channel, and resizes it to a
standard resolution before applying colorization models to predict the chrominance (ab)
channels. The resulting colorized images are visualized alongside the original and input
grayscale images using Matplotlib.
The performance evaluation of the project involves assessing image quality, diversity
project aims to provide a user-friendly solution for image colorization while offering
insights into performance, limitations, and areas for future development.
14
6.2 Key objectives:
Develop a Python script to perform image colorization using deep learning techniques.
Incorporate pre-trained models from the ECCV 2016 and SIGGRAPH 2017 papers into
the script for colorization.
Create a user-friendly CLI using argparse to allow users to specify input parameters
such as image path, GPU usage preference, and output file names.
Preprocess input images by extracting the luminance (L) channel and resizing it to a
standard resolution to prepare for colorization.
Apply the pre-trained models to predict the chrominance (ab) channels and generate
Visualize the original grayscale image, input grayscale image, and colorized outputs
using Matplotlib to facilitate comparison and evaluation.
Evaluate the performance of the colorization process based on metrics such as image
quality, diversity of generated images, inference speed, and scalability.
15
6.2.8 Comparison with Existing Systems:
Compare the performance of the implemented colorization method with existing sys-
tems in terms of image quality, training data, hardware requirements, and supported
textual inputs.
Propose potential areas for future improvement, including enhancing image quality con-
sistency, reducing hardware dependency, and expanding support for diverse textual in-
puts.
equipped with pre-trained models sourced from influential research papers such as
ECCV 2016 and SIGGRAPH 2017, ensuring state-of-the-art colorization capabilities.
cessing and postprocessing steps, the project ensures the seamless integration of input
images into the colorization pipeline, culminating in vivid and accurately colorized out-
puts.
16
into the efficacy and limitations of the implemented system. By conducting compara-
tive analyses with existing systems and identifying areas for improvement and future
research, the project empowers users with a comprehensive understanding of the land-
scape of image colorization techniques. Ultimately, the project’s contributions extend
6.3.2 Achievements:
The image colorization project has achieved significant milestones that underscore its
image colorization but also empowers users with a versatile tool for creative expression
and restoration.
17
6.4 Recommendations for future work
Continuously refine and optimize the colorization models to improve color accuracy,
reduce artifacts, and enhance overall image quality. This may involve experimenting
Expand the training dataset to include a more diverse range of images, encompassing
various scenes, objects, and lighting conditions. Incorporating domain-specific datasets
or fine-tuning models on target domains can further improve colorization performance.
Enhance support for textual input prompts to provide users with more flexibility in guid-
ing the colorization process. This could involve exploring advanced natural language
processing techniques to interpret and incorporate textual descriptions more effectively.
Optimize the codebase for better utilization of hardware resources, including CPUs and
vide users with a more intuitive and interactive experience for image colorization. This
can include features such as real-time preview, brush-based corrections, and batch pro-
cessing capabilities.
18
6.4.6 Community Engagement:
of experiences, and contributions from users and developers. This can involve organiz-
ing workshops, hackathons, or online forums to exchange ideas and address common
challenges.
Enhance the project’s documentation with comprehensive guides, tutorials, and exam-
ples to help users understand and leverage its capabilities effectively. Providing detailed
explanations of colorization techniques, implementation details, and troubleshooting
tips can empower users to make the most out of the project.
Explore opportunities for integrating the colorization project with other image process-
ing tools, libraries, or platforms. This can include interoperability with popular frame-
works like OpenCV or integration into larger software ecosystems for seamless work-
flow integration.
19
Bibliography
[1] Ambika Sharma, Abhinash Singla and Rajdavinder Singh Boparai(2012). “COL-
[2] Fan, J., Xie, W., and Ge, T. (2022). Automatic Gray Image Coloring Method
Based on Convolutional Network. Computational Intelligence and Neuroscience,
2022
[3] Sarapu, R., Viswanadam, A., Devulapally, S., Nenavath, H., and Ashwini, K.
(2021, December). Automatic colorization of black and white images using con-
[4] Smith, J., and Doe, J. (2021). Text to Image using Deep Learning.
https://www.researchgate.net/publication/359441889TexttoImageusingDeepLearning
20
Appendices
21
Appendix A
Source code
A project description is a high-level overview of why you’re doing a project. The docu-
ment explains a project’s objectives and its essential qualities. Think of it as the elevator
pitch that focuses on what and why without delving into how.
1 import argparse
2 import m a t p l o t l i b . pyplot as p l t
3
4 from c o l o r i z e r s i m p o r t *
5
6 p a r s e r = argparse . ArgumentParser ( )
7 p a r s e r . a d d a r g u m e n t ( ’ − i ’ , ’ −− i m g p a t h ’ , t y p e = s t r , d e f a u l t = ’ imgs / i 1 .
jpeg ’ )
8 p a r s e r . a d d a r g u m e n t ( ’ −− u s e g p u ’ , a c t i o n = ’ s t o r e t r u e ’ , h e l p = ’ w h e t h e r
t o u s e GPU ’ )
9 p a r s e r . a d d a r g u m e n t ( ’ −o ’ , ’ −− s a v e p r e f i x ’ , t y p e = s t r , d e f a u l t = ’ s a v e d ’ ,
h e l p = ’ w i l l s a v e i n t o t h i s f i l e w i t h { e c c v 1 6 . png , s i g g r a p h 1 7 . png }
suffixes ’)
10 opt = parser . p ars e ar gs ( )
11
12 # load c o l o r i z e r s
13 c o l o r i z e r e c c v 1 6 = eccv16 ( p r e t r a i n e d =True ) . e v a l ( )
14 c o l o r i z e r s i g g r a p h 1 7 = s i g g r a p h 1 7 ( p r e t r a i n e d =True ) . e v a l ( )
15 i f ( opt . use gpu ) :
16 c o l o r i z e r e c c v 1 6 . cuda ( )
17 c o l o r i z e r s i g g r a p h 1 7 . cuda ( )
18
19 # d e f a u l t s i z e t o p r o c e s s i m a g e s i s 256 x256
20 # g r a b L c h a n n e l i n b o t h o r i g i n a l ( ” o r i g ” ) and r e s i z e d ( ” r s ” )
resolutions
21 img = l o a d i m g ( o p t . i m g p a t h )
22 ( t e n s l o r i g , t e n s l r s ) = p r e p r o c e s s i m g ( img , HW= ( 2 5 6 , 2 5 6 ) )
23 i f ( opt . use gpu ) :
24 t e n s l r s = t e n s l r s . cuda ( )
25
26 # c o l o r i z e r o u t p u t s 256 x256 ab map
27 # r e s i z e and c o n c a t e n a t e t o o r i g i n a l L c h a n n e l
28 img bw = p o s t p r o c e s s t e n s ( t e n s l o r i g , t o r c h . c a t ( ( 0 * t e n s l o r i g , 0 *
t e n s l o r i g ) , dim = 1 ) )
29 out img eccv16 = po stpr oce ss te ns ( t e n s l o r i g , colorizer eccv16 (
t e n s l r s ) . cpu ( ) )
22
30 out img siggraph17 = postprocess tens ( tens l orig ,
c o l o r i z e r s i g g r a p h 1 7 ( t e n s l r s ) . cpu ( ) )
31
32 p l t . i m s a v e ( ’%s e c c v 1 6 . png ’%o p t . s a v e p r e f i x , o u t i m g e c c v 1 6 )
33 p l t . i m s a v e ( ’%s s i g g r a p h 1 7 . png ’%o p t . s a v e p r e f i x , o u t i m g s i g g r a p h 1 7 )
34
35 plt . figure ( f i g s i z e =(12 ,8) )
36 plt . subplot (2 ,2 ,1)
37 plt . imshow ( img )
38 plt . t i t l e ( ’ Original ’ )
39 plt . axis ( ’ off ’ )
40
41 plt . subplot (2 ,2 ,2)
42 plt . imshow ( img bw )
43 plt . t i t l e ( ’ Input ’ )
44 plt . axis ( ’ off ’ )
45
46 plt . subplot (2 ,2 ,3)
47 plt . imshow ( o u t i m g e c c v 1 6 )
48 plt . t i t l e ( ’ O u t p u t (ECCV 1 6 ) ’ )
49 plt . axis ( ’ off ’ )
50
51 plt . subplot (2 ,2 ,4)
52 plt . imshow ( o u t i m g s i g g r a p h 1 7 )
53 plt . t i t l e ( ’ O u t p u t ( SIGGRAPH 1 7 ) ’ )
54 plt . axis ( ’ off ’ )
55 plt . show ( )
23
Appendix B
Screen shots
24
Figure B.2: Sample Code
25
Figure B.4: Sample Output 2
26
Appendix C
The ImageNet dataset is a very large collection of human annotated photographs de-
training deep learning models, particularly in the field of computer vision. It contains
millions of labelled images belonging to thousands of categories.
Started in 2009, the ImageNet Large Scale Visual Recognition Challenge (ILSVRC)
was a pivotal event that popularized the dataset and benchmarked progress in image
classification algorithms.
27