Deep Learning can be fun. You give it some cat and dog photos — and it can figure out which photos are of cats and which photos are of dogs. Conversely, you can use techniques like Perceptual loss or GANs (Generative Adversarial Networks) to turn dogs into cats i.e. turn one image into another.
There are various applications of this. From amazing AI Art like transferring a style of painting to a photo: https://towardsdatascience.com/artistic-style-transfer-b7566a216431
To turning colorizing black and white images. Which is what I did. But before we do that let’s understand why this works.
Really — how deep learning works on a basic level is you show the model a bunch of data and then the desired outcome (labels). And it figures out the patterns that map the data to the labels on its own.
Similarly — in this case what we can do is take a bunch of colored photos and convert them into black and white images. A comparatively easier task as we are removing information rather than adding it. You can do this easily in Python using a library such as Pillow.
So now the colored photos are our data and the black and white corresponding images are our labels. We can then train the model to understand the mapping between these two datasets and it will learn how a black and white photo looks like in color. Once we have it trained we can use it to colorize any black and white photo.
And now the fun part begins when we get to test this out!
I wanted to pick some historical images of Pakistan. There is an awesome Facebook group called Vintage Pakistan that posts historical images and it’s really cool to see the country’s history through these images. I grabbed a few of them to see how they would come out.
Not bad. We can see there are some weird colorings in some areas and the model seems to gravitate towards a dull beige-like color so there is room for improvement.
The green tinge on the road might be because the model is getting pavement and grass mixed up.
Still though — the images don’t look half bad :)
The famed poet Faiz Ahmad Faiz in action
It even does a decent job for old(er) photos that are of lower quality with a yellowish tinge.
And of course this gem…
The first stock exchange in Pakistan!
I’ll keep playing around and maybe follow up with more. Let me know if you have suggestions for photos you would like to see colorized.