KenKaneki3/LipReading-AI
LipNet โ 3D CNN-LSTM Lip Reading Model ๐
Silent Video to Text using Deep Learning
A TensorFlow implementation of lip reading trained on the GRID corpus. The model watches silent video of a person's lips and transcribes what they're saying โ no audio required. Includes a full Streamlit web app for live demo.
Results
Sample predictions after 100 epochs:
Real: place green by y five soon
Predicted: place green by y five soon โ
Real: lay blue at y zero please
Predicted: lay blue at y zero please โ
Real: bin green with b five soon
Predicted: bin green with b five soon โ
Real: bin red by m six now
Predicted: bin red by v six now (1 word off)
Real: set green in o seven soon
Predicted: set green in s seven soon (1 word off)Architecture
Input: 75-frame grayscale video (75 ร 46 ร 140 ร 1)
โ
โผ
Conv3D(128, 3ร3ร3) โ ReLU โ MaxPool3D(1ร2ร2)
Conv3D(256, 3ร3ร3) โ ReLU โ MaxPool3D(1ร2ร2)
Conv3D(75, 3ร3ร3) โ ReLU โ MaxPool3D(1ร2ร2)
โ
โผ
TimeDistributed(Flatten)
โ
โผ
Bidirectional LSTM(128) โ Dropout(0.5)
Bidirectional LSTM(128) โ Dropout(0.5)
โ
โผ
Dense(vocab_size + 1, softmax)
โ
โผ
CTC Decode โ Text outputStreamlit App
A full web interface for running predictions on any GRID video.
cd app
streamlit run streamlitapp.pyThe app lets you select any video from the dataset and shows:
- The original video (converted to mp4)
- The cropped lip region the model sees (as a GIF)
- The raw token output from the model
- The final decoded text prediction
Setup
Prerequisites
- Python 3.10+
- TensorFlow 2.x
- Google Colab (recommended for training โ requires GPU)
Dataset
Download the GRID corpus (Speaker S1) from the official source:
- Videos:
http://spandh.dcs.shef.ac.uk/gridcorpus/ - Place videos in
data/s1/and alignment files indata/alignments/s1/
Install dependencies
pip install tensorflow opencv-python matplotlib imageio streamlit gdown numpyRun the notebook
Open LipNet.ipynb in Google Colab with T4 GPU runtime enabled.
To use pre-trained weights, download checkpoint.weights.h5 and load:
model.load_weights('models/checkpoint.weights.h5')Project Structure
LipReading_AI/
โโโ app/
โ โโโ streamlitapp.py # Streamlit web interface
โ โโโ modelutil.py # Model architecture + weight loading
โ โโโ utils.py # Video preprocessing + alignment loading
โโโ models/
โ โโโ checkpoint.weights.h5
โโโ LipNet.ipynb # Training notebook
โโโ README.md
โโโ .gitignoreData Pipeline
Each video is processed as follows:
- Frames extracted via OpenCV, converted to grayscale
- Lip region cropped:
frame[190:236, 80:220]โ resized to46ร140 - Padded or truncated to exactly 75 frames
- Normalized:
(frames - mean) / std
Alignment files are parsed to extract spoken words, filtered for silence tokens (sil), and converted to character-level integer sequences for CTC training.
Training Details
- Loss: CTC (Connectionist Temporal Classification) โ handles variable-length sequence alignment without requiring frame-level labels
- Optimizer: Adam, initial lr=0.0001, exponential decay after epoch 30
- Batch size: 2 (constrained by GPU memory)
- Train/test split: 450 / 50 batches
Limitations
- Trained on a single speaker (S1) โ will not generalize to unseen speakers without retraining
- GRID corpus uses a constrained vocabulary (~50 words) โ not suitable for open-vocabulary lip reading
- To improve generalization: add more GRID speakers (
s2,s3, ...) or fine-tune on LRW dataset
Tech Stack
- TensorFlow / Keras โ model training and CTC loss
- OpenCV โ video frame extraction and preprocessing
- NumPy โ array manipulation and WER calculation
- Streamlit โ web app interface
- Google Colab โ T4 GPU training environment
License
MIT
