CoolFace
Apppublic

Umaim/image-captioning-seq2seq

sourceHugging Facemitupdated 8mo agoView on Hugging Face
1likes
App README

๐Ÿ–ผ๏ธ Image Caption Generator

An AI-powered image captioning application using ResNet-50 encoder and LSTM decoder with attention mechanism.

Features

  • โ€”ResNet-50 Encoder: Extracts visual features from images
  • โ€”LSTM Decoder: Generates captions with attention mechanism
  • โ€”Two Decoding Strategies:
  • โ€”Greedy Search: Fast, picks most probable word at each step
  • โ€”Beam Search: Explores multiple candidates for richer captions
  • โ€”Beautiful Dark Theme UI: Modern, responsive interface

Model Architecture

  1. 1.Image โ†’ ResNet-50 (pretrained)
  2. 2.Features โ†’ Linear Encoder (2048 โ†’ 512)
  3. 3.Decoder โ†’ LSTM with Embedding (300d) + Attention
  4. 4.Output โ†’ Natural language caption

Training

  • โ€”Dataset: Flickr8k
  • โ€”Vocabulary Size: Dynamic (from training data)
  • โ€”Max Caption Length: 20 tokens

Usage

  1. 1.Upload an image (JPG, PNG, or JPEG)
  2. 2.Select decoding strategy (Greedy or Beam Search)
  3. 3.Click "Generate Caption"
  4. 4.View the AI-generated description

Technical Stack

  • โ€”PyTorch - Deep learning framework
  • โ€”Streamlit - Web interface
  • โ€”torchvision - Pre-trained ResNet-50
  • โ€”NLTK - Text processing

Files

  • โ€”app.py - Main Streamlit application
  • โ€”caption_model.pkl - Trained encoder/decoder weights + vocabulary
  • โ€”requirements.txt - Python dependencies
  • โ€”Dockerfile - Container configuration for deployment

Local Development

bash
# Install dependencies
pip install -r requirements.txt

# Run the app
streamlit run app.py

Acknowledgments

Built with โค๏ธ using PyTorch and Streamlit