Content Based Image Retrieval Using Autoencoders ( vgg19 and convolutional neural network)

Arunadevi Ramesh
3 min readJul 10, 2020

--

In this article, Autoencoders can be used for finding similar images in an unlabeled image dataset. Autoencoders are neural networks comprised of both an encoder and a decoder. The goal is to compress your input data with the encoder, then decompress the encoded data with the decoder such that the output is a good reconstruction of your original input data.

This method work with a small training database of 5 common classes : tom, jerry, building, human faces and some food items. Content based image retrieval (CBIR) systems enable to find similar images to a query image among an image dataset. This article uses the deep learning framework to perform image retrieval unlabeled image dataset. This CBIR system will be based on a convolutional autoencoder. It is a class of unsupervised deep learning algorithms.we used three methods such as convAE, simpleAE and vgg16. Basically we first extract features from an image database and store it. Then compute the features associated with a query image. Finally Retrieve images with the closest features.

Usage of high RAM is only disadvantages in this model. But still, this model can return good accuracy.

COLLECTING THE DATASET

Dataset consists of 5 common item classes: tom, jerry, building, human faces and some food items.Here is a Dataset Link for the image retrieval dataset which consists of 57 images for training (Fig 1) and 7 images for testing.

Fig 1: Small Training Images

MODEL ARCHITECTURE DEPLOYMENT

We tend to have 3 hidden layers for encoded, you can experiment with more or fewer layers that is up to you. I am going to follow the traditional approach of increasing the neurons as we go deep inside the layer; as it helps to learn more features from the image which returns us better certainty.We are going to have (100,100,3) input neurons that are we are resizing our data to 100*100 with 3 channels as it is considered to be the ideal size and therefore our model can grasp even minutiae and necessary features from the image.Next three hidden layers for decoded using encoded images.(Fig 2)

Fig 2: Model Architecture Deployment

K-NEAREST-NEIGHBOUR MODEL

After training our autoencoder model using vgg19 or convolutional neural networks, Fit the training model using K-Nearest Neighbour model (Fig 3) because KNN is used to display top kth similar images.

Fig 3: K-Nearest-Neighbour Model

SIMILAR IMAGE RETRIEVAL FOR TESTING IMAGES

After we trained our model, Now lets test a random image. A top two similar test image retrieval from the training images (Fig 4).

Fig 4: Test image retrieval from the training set

Source Code

The whole source code can be found at my Github Repository:- Image Retrieval using autoencoders source code

As always, thank you so much for reading, and please share this article if you found it useful!

--

--