Skip to content

stha1122/Image_Caption_Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Introduction

In recent years, there has been a growing interest in leveraging deep learning techniques to bridge the gap between computer vision and natural language understanding. Image captioning, a task that involves generating human-like descriptions for images, has emerged as a compelling application of this interdisciplinary research. By enabling machines to understand and describe visual content in natural language, image captioning holds promise for a wide range of applications, including assistive technologies for the visually impaired, content-based image retrieval, and enhancing human-computer interaction. ​

Project Goals

The primary objective of this project is to develop a deep learning model capable of generating descriptive captions for images automatically. We aim to harness the complementary strengths of CNNs and LSTMs to extract meaningful image features and generate coherent textual descriptions. By training our model on the Flickr8k dataset, we seek to demonstrate its ability to produce accurate and contextually relevant captions for a diverse range of images. ​

Dataset Description

We will be using the Flickr8k dataset, a widely used benchmark dataset for image captioning research. The dataset consists of 8,000 images collected from the Flickr website, each paired with five descriptive captions. These captions provide rich and diverse annotations for the images, covering a wide range of semantic concepts and linguistic styles. By leveraging this dataset, we can train our model to understand the visual content of images and generate corresponding textual descriptions effectively.

Model Architecture:

​ Our image captioning model architecture combines the strengths of Convolutional Neural Networks (CNNs) and Long Short-Term Memory networks (LSTMs). Here's how it works:

511136_1_En_8_Fig1_HTML

Convolutional Neural Network (CNN):

​ We utilize a pre-trained CNN, such as VGG16 or ResNet, to extract features from input images. In the provided code, we use the VGG16 model pre-trained on the ImageNet dataset. By removing the fully connected layers of the CNN and keeping the convolutional layers, we obtain a fixed-size feature vector representing each image's visual content. ​

Long Short-Term Memory network (LSTM):

​ The LSTM component processes the image features extracted by the CNN and generates captions word by word. In the code, we implement an LSTM-based sequence-to-sequence architecture, where the image features serve as input to the LSTM decoder. The LSTM decoder generates a sequence of words one token at a time, conditioning each word on the previously generated words and the image features.

Training Process:

​ Our model is trained using the Flickr8k dataset, following these steps: ​

Feature Extraction:

​ We use the pre-trained CNN (VGG16) to extract image features. These features are obtained by passing each image through the CNN and extracting the output of a specific layer. In the provided code, we extract features from the 'block5_conv3' layer of VGG16, resulting in a 7x7x512 feature tensor for each image. ​

Caption Generation:

​ The LSTM decoder takes the image features and generates captions word by word. During training, the LSTM decoder is fed the image features along with the start token "" to initiate the caption generation process. The decoder generates the next word in the sequence based on the previous word and the image features, using teacher forcing to provide the ground truth word at each step.

Evaluation and Fine-Tuning:

​ We evaluate the model's performance using metrics such as BLEU score, which compares the generated captions with the reference captions. Hyperparameters like learning rate, batch size, and optimizer settings are fine-tuned to improve the model's performance on the validation set.

Ouput

image

About

Image Caption Generator using CNN and LSTM

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published