Skip to content

DeepeshKafalatiya/VisionVoice

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ™οΈ VisionVoice

AI-Powered Image Captioning with Live Camera & Audio Output

Python TensorFlow OpenCV Keras Status


VisionVoice is a deep learning system that clicks a live photo via webcam,
generates a natural language caption using InceptionV3 + LSTM, and speaks it aloud β€” all in real time.



πŸ“Œ Table of Contents


🧠 How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€-─────────────┐
β”‚   Webcam     β”‚ β–Ά     InceptionV3 CNN  β”‚ β–Ά    Feature Vector       β”‚
β”‚  (OpenCV)    β”‚    β”‚  (ImageNet)       β”‚    β”‚  (2048 dimensions)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    └─────────-β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                         β”‚
                                                         β–Ό
                                             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                             β”‚  Encoder Dense (512) β”‚
                                             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                         β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                β”‚
β”‚  [startseq]  │───▢│  Embedding (512)  β”‚β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚  (seed word) β”‚    β”‚  + LSTM (512)     β”‚       (merged via add)
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚
                                                        β–Ό
                                             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                             β”‚  Decoder Dense (512) β”‚
                                             β”‚  β†’ softmax β†’ word    β”‚
                                             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                        β”‚
                                              Repeat until 'endseq'
                                                        β”‚
                                                        β–Ό
                                             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                             β”‚  pyttsx3  β†’  Speak   β”‚
                                             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Project Structure

VisionVoice/
β”‚
β”œβ”€β”€ πŸ“‚ data/
β”‚   β”œβ”€β”€ πŸ“‚ Images/              ← Dataset images + captured.jpg saved here
β”‚   └── πŸ“„ captions.txt         ← Flickr8k-style captions file
β”‚
β”œβ”€β”€ πŸ“„ extract_features.py      ← Step 1 : Extract InceptionV3 features
β”œβ”€β”€ πŸ“„ preprocess.py            ← Step 2 : Tokenize captions, save mapping
β”œβ”€β”€ πŸ“„ model_structure.py       ← Reference: print model summary anytime
β”œβ”€β”€ πŸ“„ train.py                 ← Step 3 : Train the LSTM caption model
β”œβ”€β”€ πŸ“„ camera.py                ← OpenCV webcam module (capture on SPACEBAR)
β”œβ”€β”€ πŸ“„ voice.py                 ← pyttsx3 text-to-speech helper
β”œβ”€β”€ πŸ“„ main.py                  ← Step 4 : Run the live demo end-to-end

πŸ› οΈ Tech Stack

Technology Role
Python 3.8+ Core language
TensorFlow / Keras Model training & inference
InceptionV3 CNN image feature extractor (pretrained, ImageNet)
LSTM Sequence model for caption generation
OpenCV Live webcam capture with countdown
pyttsx3 Offline text-to-speech engine
Matplotlib Display captured image with generated caption
tqdm Progress bar during feature extraction

βš™οΈ Installation

1. Clone the repository

git clone https://github.com/your-username/VisionVoice.git
cd VisionVoice

2. Install all dependencies

pip install tensorflow numpy matplotlib pyttsx3 tqdm opencv-python

3. Prepare the dataset

  • Download Flickr8k from Kaggle
  • Place all images inside β†’ data/Images/
  • Place captions.txt inside β†’ data/

πŸš€ How to Run

Run the steps in order, once. After that, only main.py is needed every time.

Step 1 β€” Extract Features

python extract_features.py

Reads every image in data/Images/ through InceptionV3 and saves 2048-dim vectors.
Output: features.pkl


Step 2 β€” Preprocess Captions

python preprocess.py

Cleans captions, fits a tokenizer, computes max caption length.
Output: tokenizer.pkl, mapping.pkl, max_length.txt


Step 3 β€” Train the Model

python train.py

Trains for up to 30 epochs with early stopping. Resumes automatically if interrupted.
Output: vision_voice_model.keras
Target loss: below 3.0


Step 4 β€” Run the Live Demo

python main.py
Step What Happens
1 Webcam opens with live 720p preview
2 3-second countdown starts on SPACEBAR
3 Photo captured & saved to data/Images/captured.jpg
4 InceptionV3 extracts features from the photo
5 LSTM decodes caption word-by-word
6 Image displayed with caption as title
7 Caption spoken aloud via pyttsx3

πŸ“· Camera Controls

Key Action
SPACEBAR Start 3-second countdown β†’ capture photo
Q Quit camera without capturing

πŸ“Š Pipeline Overview

extract_features.py  β†’  features.pkl
preprocess.py        β†’  tokenizer.pkl + mapping.pkl + max_length.txt
train.py             β†’  vision_voice_model.keras
main.py              β†’  loads all of the above + camera.py + voice.py

πŸ—‚οΈ File Generation Summary

File Created By Used By
features.pkl extract_features.py train.py, main.py
tokenizer.pkl preprocess.py train.py, main.py
mapping.pkl preprocess.py train.py
max_length.txt preprocess.py train.py, main.py
vision_voice_model.keras train.py main.py
data/Images/captured.jpg camera.py main.py


⭐ If you found this project helpful, give it a star! ⭐

About

No description, website, or topics provided.

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Jupyter Notebook 100.0%