An end-to-end deep learning image captioning and storytelling system featuring an interactive parallax web interface, Vision Transformer + GPT-2 encoder-decoder models, multi-style generation (Short, Balanced, Detailed Story), and custom PyTorch training pipelines for the Flickr30k dataset.
- Short: Crisp 8β10 word caption highlighting primary subjects, actions, and objects (ideal for Alt-Text and accessibility).
- Balanced: Structured multi-sentence paragraph analyzing the setting, atmosphere, color palette, and contextual cues.
- Detailed Narrative: Creative narrative story exploring emotional depth, environmental background, character motivation, and visual composition.
- Vision Transformer (ViT) & GPT-2: Pre-trained Vision-Encoder-Decoder model with beam search decoding.
- Dual Visual Feature Fusion (DEFF): Combines global scene context with localized visual embeddings.
- Story Generator: Fine-tuned Transformer decoder mapping visual cues into multi-paragraph stories.
- BLEU Evaluation: Automated BLEU-1 through BLEU-4 metrics for evaluation.
- Dynamic drag-and-drop image upload.
- Real-time generation with style toggle buttons.
- One-click copy, audio playback, and export.
git clone https://github.com/harshrameshnerkar/Image-Caption-Generator.git
cd Image-Caption-Generatorpip install -r requirements.txtpython app.py(Or double-click start_app.bat on Windows)
Open your browser at http://localhost:5000.
Image-Caption-Generator/
βββ app.py # Main Flask web application entry point
βββ start_app.bat # 1-click Windows launch script
βββ requirements.txt # Project dependencies
βββ index.html # Showcase and portfolio page
βββ README.md # Complete documentation
β
βββ π§ Custom Model Architectures & Training
β βββ model.py # Visual feature fusion (DEFF) + Transformer Decoder
β βββ story_model.py # Multi-style story generation model
β βββ dataset.py # PyTorch Dataset loaders
β βββ train_caption.py # Caption model training script
β βββ train_story.py # Story model fine-tuning script
β βββ generate_all_texts.py # Multi-mode caption generation from checkpoints
β βββ sample_captions.py # Beam search sample generation
β βββ extract_features.py # Image feature extraction
β βββ eval_bleu.py # BLEU evaluation
β
βββ π¦ Model Weights & Tokenizers
β βββ model_weights/ # Keras/PyTorch model weights
β βββ tokenizer/ # Tokenizer vocabulary indices
β βββ storage/ # Feature mappings & vocabulary dictionary
β
βββ π Web Interface Assets
β βββ templates/ # Flask HTML templates
β βββ static/ # CSS, JavaScript, and UI assets
β
βββ π Research Notebooks
βββ image caption.ipynb # Interactive exploration notebook
βββ working_code.ipynb # Prototype implementation notebook
- Python 3.10+
- PyTorch >= 2.0.0
- HuggingFace Transformers >= 4.30.0
- Flask >= 2.0.0
- 4 GB RAM minimum (GPU recommended for sub-second inference)
Harsh Nerkar
- GitHub: @harshrameshnerkar
- Email: harshrameshnerkar@gmail.com
This project is licensed under the MIT License.