An Image Caption Generator built with a deep learning architecture that combines Convolutional Neural Networks (CNN) for image feature extraction and Long Short-Term Memory (LSTM) networks for generating natural language captions.
Developed for EC9170 – Deep Learning, University of Jaffna.
- Preprocessing of captions and image data
- CNN feature extraction using InceptionV3
- Sequence modeling with LSTM
- Caption generation using greedy search
- Visualization of images alongside their generated captions
├── CNN-LSTM.ipynb # Initial merged CNN + LSTM implementation
├── CNN-LSTM_final.ipynb # Final training and inference notebook ← start here
├── CNN-separate.ipynb # CNN feature extraction run separately
└── README.md
The dataset is not committed to this repository. Before running, place it alongside the notebooks:
├── images/ # 8,091 Flickr8k images
└── captions.txt # 5 captions per image
- Python 3
- TensorFlow / Keras
- NumPy, Pandas
- Matplotlib
- Scikit-learn
- Pretrained CNN: InceptionV3
- Images: 8,091 images from the Flickr8k dataset
- Captions: each image paired with 5 different captions
- Preprocessing: lowercasing, punctuation removal, tokenization
- Caption preprocessing — clean text (lowercase, strip punctuation, tokenize), wrap each caption in
<start>and<end>tokens - Image feature extraction — pretrained InceptionV3 produces a 2048-dimensional feature vector per image
- Tokenization & sequencing — captions converted to integer sequences and padded to uniform length
- CNN-LSTM model — image features and partial text sequences are merged to predict the next word
- Caption generation — greedy search decodes a caption word-by-word from the image features
-
Clone the repository:
git clone https://github.com/Jesuthan/Image-Caption-Generator-using-CNN-LSTM.git cd Image-Caption-Generator-using-CNN-LSTM -
Install dependencies:
pip install tensorflow numpy pandas matplotlib scikit-learn pillow
-
Add the dataset — download Flickr8k and place
images/andcaptions.txtin the repository root. -
Launch Jupyter and open the final notebook:
jupyter notebook CNN-LSTM_final.ipynb
-
Run all cells in order.
Image: dog.jpg
Generated Caption: a dog is running in the field
Quantitative evaluation is not yet implemented. Captions are currently assessed qualitatively by inspecting generated output against the source image.
Planned metrics: BLEU, CIDEr, ROUGE, METEOR.
- Implement BLEU/CIDEr/ROUGE/METEOR scoring for measurable performance
- Replace greedy search with beam search for higher-quality captions
- Add attention (Show, Attend and Tell) over the CNN feature map
- Deploy as a web demo using Streamlit or Flask
- Flickr8k dataset
- TensorFlow / Keras documentation
- Vinyals et al., "Show and Tell: A Neural Image Caption Generator" (2015)
Built as a group project for EC9170 – Deep Learning:
- Anushanth
- Harshini
- Jesuthan (@Jesuthan)