The problem
Describing a photo in words requires a machine to do two hard things at once — see and speak. Image captioning is the task that joins computer vision and natural language processing: a CNN reads the image, an LSTM writes the sentence, and an attention mechanism lets each word look back at the image region that inspired it. The Flickr8k dataset (8,092 photos, five human captions each) is the standard teaching benchmark. This project implements the Show, Attend and Tell architecture — ResNet-101 encoder producing a 14×14 region grid, soft attention over the 196 regions at each decoding step, beam search at inference — trains it with teacher forcing, and evaluates with BLEU, METEOR, ROUGE-L and CIDEr against the five references. The web demo generates captions for photos with hoverable per-word attention weights and ranked beam candidates.
8,092 Flickr images with 5 captions each that the encoder-decoder learns to describe photographs from.
Follow the working sequence
How it works
- Flickr8k's 8,092 images and 40,460 captions are loaded; captions are lowercased, tokenized, and a vocabulary of ~8,789 words is built (min frequency 5).
- Each image is passed through ResNet-101 once; the 14×14×2048 region features are cached to disk so training never re-encodes.
- The decoder — an embedding layer, attention LSTM (512 units) and output softmax — is trained with teacher forcing and cross-entropy for 30 epochs.
- At each step the attention layer computes weights over the 196 image regions, conditioning the next word on the attended visual context.
- At inference, beam search (width 3) explores candidate sequences and the top-scoring caption is returned.
- The test split is evaluated once: BLEU-4, METEOR, ROUGE-L and CIDEr against the five reference captions per image.
- In the web demo, a selected photo's cached region features feed the saved decoder; the app shows the caption with attention weights and beam candidates.
Tech stack:
- Python 3, PyTorch
- ResNet-101 encoder (torchvision)
- Flickr8k dataset (Hodosh et al., 2013)
- NLTK / pycocoevalcap (metrics)
- NumPy, Matplotlib
- Jupyter Notebook (training)
- HTML/CSS/JavaScript (caption demo)
Dataset & model details
- Dataset: Flickr8k — 8,092 photographs with 5 human-written captions each (40,460 captions total), standard train/val/test splits. Released by Hodosh et al. (2013).
- Task: Conditional text generation; input = 14×14×2048 region features from the photo, output = English caption (≤20 tokens) from an 8,789-word vocabulary.
- Model: Encoder: ResNet-101 (frozen, features cached). Decoder: embedding(512) → attention LSTM(512) → Dense(vocab, softmax). Soft attention over 196 regions per step; beam search width 3 at inference.
- Metrics: BLEU-4 ~0.62 (design target for the built-to-order training run), METEOR ~0.54, ROUGE-L ~0.68, CIDEr ~0.91. No metric is claimed as measured until the training run is executed for the order.
| Parameter | Value |
|---|---|
| Input format | Photograph, 224×224 for encoder |
| Vocabulary | Approximately 8,789 words |
| Dataset size | 8,092 images × 5 captions |
| Decoder parameters | Approximately 18M (design target) |
| BLEU-4 | ~0.62 (design target, not a measured claim) |
| Training time | Approximately 3–5 hours on a free cloud GPU (expected) |
| Inference | Approximately 240 ms per caption on CPU (expected) |
| Demo | Web app with attention visualization |
Project features
- [Encoder-decoder with attention] ResNet-101 encoder (14×14×2048 region grid) + soft-attention LSTM decoder — the Show, Attend and Tell design.
- [Live caption demo] Pick a photo; get a generated caption with per-word attention weights (hover to inspect) and ranked beam-search candidates.
- [Beam search decoding] Beam width 3 at inference with length normalization, replacing greedy decoding's myopia.
- [Full training notebook] Vocabulary building, feature precomputation, teacher-forced training loop and metric scoring in one reproducible notebook.
- [Captioning metrics] BLEU-4, METEOR, ROUGE-L and CIDEr computed against all five reference captions per image.
- [Attention inspection] Per-word attention weights visualized so each generated word traces to its image region.
- [Decoding comparison] Greedy vs beam-search outputs compared on sample images in the report.
What is included
- Complete training & evaluation Jupyter notebook
- Trained decoder model with cached encoder features pipeline
- Caption generator web demo (attention weights, beam candidates)
- Metric scores, attention visualizations and sample outputs
- Project report PDF (background, attention theory, methodology, results)
- PPT presentation for final review
- Viva Q&A preparation document (attention, beam search, teacher forcing, metrics)
Limitations & prerequisites
- BLEU-4 ~0.62 is a design target for the training run, stated honestly — the report documents the actual achieved figures.
- Captions describe the obvious; fine detail, text in images and precise counts are unreliable.
- The model can hallucinate objects consistent with scene context but absent from the photo — the report shows examples.
- Vocabulary is closed at ~8,789 words; rare words become
. - Flickr8k's everyday-photo domain bounds generalization; specialized imagery needs retraining.
Frequently Asked Questions
Which dataset is used?
Flickr8k — 8,092 photos with five human captions each (Hodosh et al., 2013), the standard teaching benchmark for image captioning with fixed train/val/test splits.
How does the attention mechanism work?
The encoder produces a 14×14 grid of region features. At each decoding step, the attention layer scores all 196 regions and takes a weighted sum — so the word "dog" is generated while attending to the dog region. The demo lets you hover each word to see its attention weight.
What is beam search and why use it?
Greedy decoding picks the best word at each step and can paint itself into a corner. Beam search keeps the 3 best partial captions alive and picks the best complete one — consistently better captions, compared in the report.
What is teacher forcing?
During training the decoder is fed the true previous word rather than its own prediction, which stabilizes learning. The report explains the train/inference mismatch this creates (exposure bias) and how scheduled sampling addresses it.
How are captions scored?
Against all five human references with BLEU-4 (n-gram overlap), METEOR (stem/synonym-aware), ROUGE-L (longest subsequence) and CIDEr (consensus-weighted) — four metrics because no single one captures caption quality.
Is this project suitable for a final-year project?
Yes — for Computer Science, IT and AI/ML programs. It unites vision and language, attention mechanisms and sequence decoding in one demonstrable system. Suitable for B.E./B.Tech final-year projects in Computer Science, IT and AI & Machine Learning.
Components & software requirements
- Python 3, PyTorch
- ResNet-101 encoder (torchvision)
- Flickr8k dataset (Hodosh et al., 2013)
- NLTK / pycocoevalcap (metrics)
- NumPy, Matplotlib
- Jupyter Notebook (training)
- HTML/CSS/JavaScript (caption demo)
Dataset & model details
- Dataset: Flickr8k — 8,092 photographs with 5 human-written captions each (40,460 captions total), standard train/val/test splits. Released by Hodosh et al. (2013).
- Task: Conditional text generation; input = 14×14×2048 region features from the photo, output = English caption (≤20 tokens) from an 8,789-word vocabulary.
- Model: Encoder: ResNet-101 (frozen, features cached). Decoder: embedding(512) → attention LSTM(512) → Dense(vocab, softmax). Soft attention over 196 regions per step; beam search width 3 at inference.
- Metrics: BLEU-4 ~0.62 (design target for the built-to-order training run), METEOR ~0.54, ROUGE-L ~0.68, CIDEr ~0.91. No metric is claimed as measured until the training run is executed for the order.
Delivery information
Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.
Support terms
Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.
Download free synopsis (PDF)
Enter your name and WhatsApp number — the synopsis PDF downloads immediately. We may send occasional project updates on WhatsApp; no spam.