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.
- How It Works
- Project Structure
- Tech Stack
- Installation
- How to Run
- Pipeline Overview
- Camera Controls
- File Generation Summary
ββββββββββββββββ βββββββββββββββββββββ ββββββββββ-ββββββββββββββ
β 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 β
ββββββββββββββββββββββββ
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
| 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 |
1. Clone the repository
git clone https://github.com/your-username/VisionVoice.git
cd VisionVoice2. Install all dependencies
pip install tensorflow numpy matplotlib pyttsx3 tqdm opencv-python3. Prepare the dataset
- Download Flickr8k from Kaggle
- Place all images inside β
data/Images/ - Place
captions.txtinside βdata/
Run the steps in order, once. After that, only main.py is needed every time.
python extract_features.pyReads every image in data/Images/ through InceptionV3 and saves 2048-dim vectors.
Output: features.pkl
python preprocess.pyCleans captions, fits a tokenizer, computes max caption length.
Output: tokenizer.pkl, mapping.pkl, max_length.txt
python train.pyTrains for up to 30 epochs with early stopping. Resumes automatically if interrupted.
Output: vision_voice_model.keras
Target loss: below 3.0
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 |
| Key | Action |
|---|---|
SPACEBAR |
Start 3-second countdown β capture photo |
Q |
Quit camera without capturing |
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 | 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! β