You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Colorize Grayscale images using Convolutional Autoencoders
Why CIFAR10?
The data has a lot of categories, and these are really small images, so I can iterate quickly. But the same method can be used on bigger images.
The data
Each image is of dims 32x32x3
I downloaded the dataset from the cifar website and I am using torchvision's inbuilt dataloaders to make my life easy. Essentially its a numpy array.
Lets take a look at one of the images
Lets create some training data.
The objective is to convert rgb images to grayscale.
Although traditional image processing methods would work better, this is somthing a neural network can also do.
Some important things to consider
I will be using opencv's RGB2GRAY.
OpenCV's COLOR_RGB2GRAY uses a weighted approach for grayscale conversion.
Generating train and test data
I will use a train test split of 0.8, 0.2 and I will be using a batch_size of 100.
Just making sure everything is as expected.
Lets talk about the model
I will use a convolutional auto-encoders.
In my autoencoder architecture, I have 2 layers of convolution at the encoder with maxpool applied to both the convolutions, in the decoder, I have a couple of deconvolution layers. The final layer is a fully connected layer that outputs a vector of batch_size x 1024.
optimizer = Adam (I have not added any weight decay as the model did not seem to be over-fitting, infact, due to the network being relatively shallow, the model is underfitting.)
Training and Test losses
Input to the model
Predictions from the model
Actual images
Conclustions
From the the results, we can see that the model has learnt to transfrom grayscale images to RGB images.
In the current apporach the model gives out an image that is blurry, which can be improved with a bit more model complexity.
About
This repo contains a Pytorch implementation of Convolutional Autoencoder, used for converting grayscale images to RGB.