# weizhi-zhong/ip_lap architecture

> Architecture diagram of the GitHub repository weizhi-zhong/ip_lap, 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/weizhi-zhong/ip_lap
- Repository: https://github.com/weizhi-zhong/ip_lap

## Overview

IP_LAP is a research implementation for identity-preserving talking-face generation. Its main workflow takes a source video and driving audio, extracts facial landmarks and audio features, predicts motion landmarks, then renders an animated face. The repository also supports dataset preprocessing and separate training of the landmark generator and video renderer. The graph combines sampled code relationships with README-documented stages; some inference and training internals are only partially excerpted, so uncertain links are omitted.

Main entry points: [`inference_single.py`](https://github.com/weizhi-zhong/ip_lap/blob/main/inference_single.py) (Single-video inference), [`train_video_renderer.py`](https://github.com/weizhi-zhong/ip_lap/blob/main/train_video_renderer.py) (Renderer training), [`preprocess/preprocess_audio.py`](https://github.com/weizhi-zhong/ip_lap/blob/main/preprocess/preprocess_audio.py) (Audio preprocessing), [`preprocess/preprocess_video.py`](https://github.com/weizhi-zhong/ip_lap/blob/main/preprocess/preprocess_video.py) (Video preprocessing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Dataset preprocessing"]
  node_audio_prep["Audio preprocessing"]
  node_video_prep["Video preprocessing"]
end

subgraph group_models["Generation models"]
  node_audio_features["Audio features<br/>[audio.py]"]
  node_landmark_drawing["Landmark utilities<br/>[draw_landmark.py]"]
  node_landmark_model["Landmark generator"]
  node_renderer["Video renderer<br/>[video_renderer.py]"]
  node_discriminator["Multiscale discriminator<br/>[pix2pixHD_disc.py]"]
end

subgraph group_training["Model training"]
  node_losses["Perceptual and GAN losses<br/>[loss.py]"]
  node_landmark_training["Landmark training"]
  node_renderer_training["Renderer training"]
end

subgraph group_inference["Inference"]
  node_source_video["Source video"]
  node_driving_audio["Driving audio"]
  node_inference["Single-video inference"]
end

node_dataset[("LRS2 videos")]
node_user(("User"))
node_generated_video["Generated video"]

node_dataset -->|"extracts audio"| node_audio_prep
node_dataset -->|"extracts frames"| node_video_prep
node_audio_prep -->|"computes mels"| node_audio_features
node_audio_prep -->|"provides audio data"| node_landmark_training
node_video_prep -->|"provides landmarks"| node_landmark_training
node_video_prep -->|"provides faces and sketches"| node_renderer_training
node_audio_prep -->|"provides audio data"| node_renderer_training
node_landmark_training -->|"trains"| node_landmark_model
node_renderer_training -->|"trains"| node_renderer
node_renderer_training -->|"uses losses"| node_losses
node_renderer_training -.->|"configures model"| node_discriminator
node_user -->|"runs"| node_inference
node_source_video -->|"supplies video"| node_inference
node_driving_audio -->|"supplies audio"| node_inference
node_inference -->|"uses landmarks"| node_landmark_drawing
node_inference -->|"extracts mels"| node_audio_features
node_inference -.->|"predicts landmarks"| node_landmark_model
node_inference -.->|"renders frames"| node_renderer
node_inference -->|"produces"| node_generated_video

click node_audio_prep "https://github.com/weizhi-zhong/ip_lap/blob/main/preprocess/preprocess_audio.py"
click node_video_prep "https://github.com/weizhi-zhong/ip_lap/blob/main/preprocess/preprocess_video.py"
click node_audio_features "https://github.com/weizhi-zhong/ip_lap/blob/main/models/audio.py"
click node_landmark_drawing "https://github.com/weizhi-zhong/ip_lap/blob/main/draw_landmark.py"
click node_landmark_model "https://github.com/weizhi-zhong/ip_lap/blob/main/models/landmark_generator.py"
click node_renderer "https://github.com/weizhi-zhong/ip_lap/blob/main/models/video_renderer.py"
click node_discriminator "https://github.com/weizhi-zhong/ip_lap/blob/main/models/pix2pixHD_disc.py"
click node_losses "https://github.com/weizhi-zhong/ip_lap/blob/main/loss.py"
click node_landmark_training "https://github.com/weizhi-zhong/ip_lap/blob/main/train_landmarks_generator.py"
click node_renderer_training "https://github.com/weizhi-zhong/ip_lap/blob/main/train_video_renderer.py"
click node_inference "https://github.com/weizhi-zhong/ip_lap/blob/main/inference_single.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_audio_prep,node_video_prep,node_user toneBlue
class node_audio_features,node_landmark_drawing,node_landmark_model,node_renderer,node_discriminator,node_dataset toneAmber
class node_losses,node_landmark_training,node_renderer_training toneMint
class node_source_video,node_driving_audio,node_inference toneRose
class node_generated_video toneIndigo
```

## Components

### Dataset preprocessing

- [Audio preprocessing](https://github.com/weizhi-zhong/ip_lap/blob/main/preprocess/preprocess_audio.py): `preprocess/preprocess_audio.py`
- [Video preprocessing](https://github.com/weizhi-zhong/ip_lap/blob/main/preprocess/preprocess_video.py): `preprocess/preprocess_video.py`

### Generation models

- [Audio features](https://github.com/weizhi-zhong/ip_lap/blob/main/models/audio.py): `models/audio.py`
- [Landmark utilities](https://github.com/weizhi-zhong/ip_lap/blob/main/draw_landmark.py): `draw_landmark.py`
- [Landmark generator](https://github.com/weizhi-zhong/ip_lap/blob/main/models/landmark_generator.py): `models/landmark_generator.py`
- [Video renderer](https://github.com/weizhi-zhong/ip_lap/blob/main/models/video_renderer.py): `models/video_renderer.py`
- [Multiscale discriminator](https://github.com/weizhi-zhong/ip_lap/blob/main/models/pix2pixHD_disc.py): `models/pix2pixHD_disc.py`

### Model training

- [Perceptual and GAN losses](https://github.com/weizhi-zhong/ip_lap/blob/main/loss.py): `loss.py`
- [Landmark training](https://github.com/weizhi-zhong/ip_lap/blob/main/train_landmarks_generator.py): `train_landmarks_generator.py`
- [Renderer training](https://github.com/weizhi-zhong/ip_lap/blob/main/train_video_renderer.py): `train_video_renderer.py`

### Inference

- **Source video**
- **Driving audio**
- [Single-video inference](https://github.com/weizhi-zhong/ip_lap/blob/main/inference_single.py): `inference_single.py`

### Other components

- **LRS2 videos**
- **User**
- **Generated video**

## Connections

- LRS2 videos → Audio preprocessing: extracts audio (evidence: `README.md`)
- LRS2 videos → Video preprocessing: extracts frames (evidence: `README.md`)
- Audio preprocessing → Audio features: computes mels (evidence: `preprocess/preprocess_audio.py`)
- Audio preprocessing → Landmark training: provides audio data (evidence: `README.md`)
- Video preprocessing → Landmark training: provides landmarks (evidence: `README.md`)
- Video preprocessing → Renderer training: provides faces and sketches (evidence: `README.md`)
- Audio preprocessing → Renderer training: provides audio data (evidence: `README.md`)
- Landmark training → Landmark generator: trains (evidence: `train_landmarks_generator.py`)
- Renderer training → Video renderer: trains (evidence: `train_video_renderer.py`)
- Renderer training → Perceptual and GAN losses: uses losses (evidence: `train_video_renderer.py`)
- Renderer training → Multiscale discriminator: configures model
- User → Single-video inference: runs (evidence: `README.md`)
- Source video → Single-video inference: supplies video (evidence: `README.md`)
- Driving audio → Single-video inference: supplies audio (evidence: `README.md`)
- Single-video inference → Landmark utilities: uses landmarks (evidence: `inference_single.py`)
- Single-video inference → Audio features: extracts mels (evidence: `inference_single.py`)
- Single-video inference → Landmark generator: predicts landmarks
- Single-video inference → Video renderer: renders frames
- Single-video inference → Generated video: produces (evidence: `README.md`)
