# piyushlavaniya/reinforcing-lipreading-with-llm architecture

> Architecture diagram of the GitHub repository piyushlavaniya/reinforcing-lipreading-with-llm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/piyushlavaniya/reinforcing-lipreading-with-llm
- Repository: https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm

## Overview

This prototype lets a user select a video, view it, and get a lip-reading prediction refined by an LLM. The app loads the selected clip and its alignment, runs a checkpoint-backed model, decodes the output into text, then sends that text to an LLM. The README describes the app as an experimental prototype. The separate AI helper is included as a capability, but the sampled app code does not call it; the graph shows only relationships visible in the excerpts.

Main entry points: [`testing_app.py`](https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/blob/main/testing_app.py) (Video app), [`utils.py`](https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/blob/main/utils.py) (Video and label loader), [`modelutil.py`](https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/blob/main/modelutil.py) (Lip-reading model), [`data/test_videos`](https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/tree/main/data/test_videos) (Test videos)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["User application"]
  node_streamlit_app["Video app<br/>[testing_app.py]"]
end

subgraph group_data["Video and labels"]
  node_video_files["Test videos"]
  node_alignments["Alignments"]
  node_video_loader["Video and label loader<br/>[utils.py]"]
end

subgraph group_inference["Lip-reading inference"]
  node_lip_model["Lip-reading model<br/>[modelutil.py]"]
  node_checkpoint["Model weights"]
  node_text_decoder["CTC text decoding<br/>[testing_app.py]"]
end

subgraph group_language["Language refinement"]
  node_prompt_chain["LLM prompt chain<br/>[testing_app.py]"]
  node_ai_helper["AI helper<br/>[aiutils.py]"]
end

node_user(("User"))
node_llm_service{{"OpenAI-compatible LLM"}}

node_user -->|"selects video"| node_streamlit_app
node_streamlit_app -->|"lists and renders"| node_video_files
node_streamlit_app -->|"loads selected data"| node_video_loader
node_video_loader -->|"reads frames"| node_video_files
node_video_loader -->|"reads labels"| node_alignments
node_streamlit_app -->|"loads model"| node_lip_model
node_lip_model -->|"loads weights"| node_checkpoint
node_streamlit_app -->|"decodes prediction"| node_text_decoder
node_streamlit_app -->|"submits decoded text"| node_prompt_chain
node_prompt_chain -->|"requests refinement"| node_llm_service
node_ai_helper -->|"requests response"| node_llm_service

click node_streamlit_app "https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/blob/main/testing_app.py"
click node_video_files "https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/tree/main/data/test_videos"
click node_alignments "https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/tree/main/data/annotations"
click node_video_loader "https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/blob/main/utils.py"
click node_lip_model "https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/blob/main/modelutil.py"
click node_checkpoint "https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/tree/main/model_checkpoint"
click node_text_decoder "https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/blob/main/testing_app.py"
click node_prompt_chain "https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/blob/main/testing_app.py"
click node_ai_helper "https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/blob/main/aiutils.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_streamlit_app,node_user toneBlue
class node_video_files,node_alignments,node_video_loader toneAmber
class node_lip_model,node_checkpoint,node_text_decoder toneMint
class node_prompt_chain,node_ai_helper toneRose
class node_llm_service toneIndigo
```

## Components

### User application

- [Video app](https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/blob/main/testing_app.py): `testing_app.py`

### Video and labels

- [Test videos](https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/tree/main/data/test_videos): `data/test_videos`
- [Alignments](https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/tree/main/data/annotations): `data/annotations`
- [Video and label loader](https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/blob/main/utils.py): `utils.py`

### Lip-reading inference

- [Lip-reading model](https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/blob/main/modelutil.py): `modelutil.py`
- [Model weights](https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/tree/main/model_checkpoint): `model_checkpoint`
- [CTC text decoding](https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/blob/main/testing_app.py): `testing_app.py`

### Language refinement

- [LLM prompt chain](https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/blob/main/testing_app.py): `testing_app.py`
- [AI helper](https://github.com/piyushlavaniya/reinforcing-lipreading-with-llm/blob/main/aiutils.py): `aiutils.py`

### Other components

- **User**
- **OpenAI-compatible LLM**

## Connections

- User → Video app: selects video (evidence: `testing_app.py`)
- Video app → Test videos: lists and renders (evidence: `testing_app.py`)
- Video app → Video and label loader: loads selected data (evidence: `testing_app.py`)
- Video and label loader → Test videos: reads frames (evidence: `utils.py`)
- Video and label loader → Alignments: reads labels (evidence: `utils.py`)
- Video app → Lip-reading model: loads model (evidence: `testing_app.py`)
- Lip-reading model → Model weights: loads weights (evidence: `modelutil.py`)
- Video app → CTC text decoding: decodes prediction (evidence: `testing_app.py`)
- Video app → LLM prompt chain: submits decoded text (evidence: `testing_app.py`)
- LLM prompt chain → OpenAI-compatible LLM: requests refinement (evidence: `testing_app.py`)
- AI helper → OpenAI-compatible LLM: requests response (evidence: `aiutils.py`)
