File size: 10,486 Bytes
9286a2f
 
 
 
 
 
 
 
 
 
 
 
 
2f8f4da
9286a2f
 
 
 
d65d9c9
9286a2f
d65d9c9
9286a2f
d65d9c9
 
 
9286a2f
 
 
 
 
d65d9c9
 
 
9286a2f
 
d65d9c9
9286a2f
d65d9c9
 
 
 
9286a2f
 
 
 
 
 
d65d9c9
2f8f4da
3fbe5ba
9286a2f
d65d9c9
9286a2f
 
d65d9c9
 
9286a2f
 
d65d9c9
9286a2f
 
d65d9c9
9286a2f
 
 
d65d9c9
 
 
 
 
 
 
9286a2f
 
 
 
 
d65d9c9
9286a2f
d65d9c9
 
 
9286a2f
d65d9c9
 
 
 
 
 
 
 
 
 
9286a2f
 
 
 
 
 
 
 
 
d65d9c9
9286a2f
 
 
d65d9c9
9286a2f
 
d65d9c9
9286a2f
 
d65d9c9
9286a2f
 
d65d9c9
9286a2f
 
d65d9c9
 
9286a2f
 
 
 
 
 
d65d9c9
9286a2f
 
 
 
 
 
 
 
d65d9c9
 
9286a2f
d65d9c9
9286a2f
 
 
 
d65d9c9
9286a2f
 
d65d9c9
 
 
 
9286a2f
 
 
 
 
 
 
 
 
 
 
 
 
d65d9c9
9286a2f
 
d65d9c9
9286a2f
 
d65d9c9
9286a2f
d65d9c9
 
9286a2f
 
 
 
 
 
d65d9c9
9286a2f
d65d9c9
9286a2f
d65d9c9
9286a2f
d65d9c9
 
 
9286a2f
 
d65d9c9
9286a2f
d65d9c9
9286a2f
 
 
 
 
d65d9c9
9286a2f
 
 
 
 
d65d9c9
 
9286a2f
 
d65d9c9
 
 
 
9286a2f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d65d9c9
9286a2f
 
d65d9c9
 
 
 
 
9286a2f
d65d9c9
9286a2f
 
 
d65d9c9
9286a2f
 
d65d9c9
 
 
9286a2f
 
 
 
 
d65d9c9
 
 
 
 
 
 
 
 
 
 
9286a2f
 
 
 
 
 
d65d9c9
9286a2f
d65d9c9
 
 
 
 
 
9286a2f
 
d65d9c9
9286a2f
d65d9c9
 
 
 
 
9286a2f
d65d9c9
9286a2f
d65d9c9
 
9286a2f
 
ae39d55
9286a2f
d65d9c9
9286a2f
d65d9c9
 
 
9286a2f
d65d9c9
9286a2f
 
 
 
d65d9c9
 
 
9286a2f
 
d65d9c9
9286a2f
 
 
 
d65d9c9
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
---
language:
- vi
license: cc-by-nc-4.0
task_categories:
- video-classification
- image-to-video
tags:
- talking-face
- landmark
- lip-sync
- vietnamese
- audio-visual
pretty_name: 'VAVD: Vietnamese Visual-Audio Dataset'
size_categories:
- 1K<n<10K
---

# Vietnamese Visual-Audio Dataset

Vietnamese audio-visual landmark dataset designed for talking-face landmark generation. The dataset is curated to support efficient fine-tuning of the pretrained [IP-LAP](https://github.com/Weizhi-Zhong/IP_LAP) model on Vietnamese speakers.

> **Note:** This dataset does not directly host video files. Instead, [`video_sources.csv`](video_sources.csv) provides the 123 public YouTube source URLs. The full dataset can be automatically downloaded and processed using [`download_dataset.py`](download_dataset.py).

---

## Dataset Summary

| Split | Clips | Speakers |
|-------|------:|--------:|
| Train | 3,541 | ~118 |
| Val | 338 | ~66 |
| Test | 239 | ~52 |
| **Total** | **4,118** | **123** |

The dataset is constructed from two sources:

- `vilap_dataset`: 1,630 clips from the main training set
- `vilap_dataset_extra_10h`: 2,488 clips from the extended crawl

The videos are collected from public Vietnamese YouTube sources, including news programs, interviews, and talk shows. Each sample is a short single-speaker clip of approximately 5 seconds, processed at 25 FPS.

---

## Quick Start

```bash
# 1. Clone the dataset repository from Hugging Face
git clone https://huggingface.co/datasets/btlam2002/VAVD
cd VAVD

# 2. Install the required dependencies
pip install yt-dlp mediapipe opencv-python librosa scipy numpy

# 3. Download and process the full dataset
# This automatically downloads videos, cuts clips, extracts faces, landmarks, and audio features
python download_dataset.py --output ./vilap_data

# Or download only the test split for a quick trial (~239 clips)
python download_dataset.py --output ./vilap_data --splits test

# Or process only specific videos
python download_dataset.py --output ./vilap_data --video_ids 3p7dFrIx5bk xwsPD6xiPbI
```

The `download_dataset.py` pipeline automatically performs the following steps:

1. **Download videos** from YouTube using `yt-dlp` with a maximum resolution of 720p.
2. **Cut clips** into 5-second segments using `ffmpeg`.
3. **Extract face crops** at 128×128 pixels using MediaPipe Face Detection.
4. **Extract landmarks** using MediaPipe Face Mesh, including 74 pose landmarks and 57 content landmarks.
5. **Extract audio features**, including 16 kHz WAV files and Mel-spectrogram `.npy` files following the IP-LAP convention.

---

## Video Sources

All video URLs are listed in [`video_sources.csv`](video_sources.csv).

| Column | Description |
|--------|-------------|
| `video_id` | YouTube video ID, also used as the speaker folder name |
| `youtube_url` | Full YouTube URL |
| `title` | Video title |
| `channel` | YouTube channel name |
| `source` | Dataset source, either `vilap_dataset` or `vilap_dataset_extra_10h` |
| `n_train_clips` | Number of clips in the training split |
| `n_val_clips` | Number of clips in the validation split |
| `n_test_clips` | Number of clips in the test split |
| `n_total_clips` | Total number of clips from the video |

Example:

```csv
video_id,youtube_url,title,channel,source,n_train_clips,n_val_clips,n_test_clips,n_total_clips
3p7dFrIx5bk,https://www.youtube.com/watch?v=3p7dFrIx5bk,Chuyên gia phân tích...,VTV24,vilap_dataset,68,1,1,70
```

---

## Directory Structure

```text
vilap_dataset/
├── 02_clips/
│   └── <speaker_id>/
│       └── <speaker_id>_cNNNN.mp4       # raw clip, 25 FPS, 1280×720
├── 03_face/
│   └── <speaker_id>/<clip_id>/
│       └── {frame_id}.png               # 128×128 face crop
├── 04_sketch/
│   └── <speaker_id>/<clip_id>/
│       └── {frame_id}.png               # optional sketch image
├── 05_landmark/
│   └── <speaker_id>/<clip_id>/
│       └── {frame_id}.npy               # per-frame landmark dictionary
└── 06_audio/
    └── <speaker_id>/<clip_id>/
        ├── audio.npy                    # Mel-spectrogram, shape [T, 80]
        └── audio.wav                    # 16 kHz mono WAV file
```

---

## Landmark Format

Each `.npy` landmark file contains a Python dictionary and can be loaded with `allow_pickle=True`.

```python
d = np.load("05_landmark/spk/spk_c0000/0.npy", allow_pickle=True).item()
# d.keys() → ['pose_landmarks', 'content_landmarks']
```

| Field | Points | Description |
|-------|-------:|-------------|
| `pose_landmarks` | 74 | Jaw and upper-face structural landmarks |
| `content_landmarks` | 57 | Lip and lower-face landmarks, including jaw `0:17`, outer lip `17:37`, and inner lip `37:57` |

Each landmark is stored as a list of `[landmark_id, x, y]` triplets, where `x` and `y` are normalized to the face crop range `[0.0, 1.0]`.

```python
# Example: read one frame
import numpy as np

d = np.load("frame_0.npy", allow_pickle=True).item()

content = d["content_landmarks"]   # list of [id, x, y], 57 points
pose = d["pose_landmarks"]         # list of [id, x, y], 74 points

# Sort landmarks according to the IP-LAP ori_sequence_idx before feeding them into the model.
```

---

## Audio Format

| Property | Value |
|----------|-------|
| Sample rate | 16,000 Hz |
| Channels | Mono |
| Mel bands | 80 |
| FFT size | 800 |
| Hop size | 200 samples |
| Frame rate | 25 FPS, aligned with video |

```python
# Load Mel-spectrogram
mel = np.load("audio.npy")   # shape: [T_mel_frames, 80]

# Extract a 16-frame Mel window for frame i following the IP-LAP convention
frame_idx = 50
audio_offset = -2           # -4 recommended offset for Vietnamese speech

start = int(80.0 * ((frame_idx + audio_offset) / 25.0))
window = mel[start : start + 16, :]   # shape: [16, 80]
```

---

## File Lists

The `filelists/` directory provides pre-computed train, validation, and test splits.

```text
filelists/
├── train.txt   # 3,541 clips, 86.0%
├── val.txt     # 338 clips, 8.2%
└── test.txt    # 239 clips, 5.8%
```

Each line stores a clip key in the format `<speaker_id>/<clip_id>`.

```text
3p7dFrIx5bk/3p7dFrIx5bk_c0000
3p7dFrIx5bk/3p7dFrIx5bk_c0001
...
```

The following example shows how to resolve the actual data paths:

```python
from pathlib import Path

DATA_BASE = Path("path/to/vilap_dataset")

clip_key = "3p7dFrIx5bk/3p7dFrIx5bk_c0017"
dirname, vidname = clip_key.split("/")

face_dir = DATA_BASE / "03_face" / dirname / vidname
lm_dir = DATA_BASE / "05_landmark" / dirname / vidname
audio_npy = DATA_BASE / "06_audio" / dirname / vidname / "audio.npy"
audio_wav = DATA_BASE / "06_audio" / dirname / vidname / "audio.wav"
```

---

## Loading a Full Clip

```python
import numpy as np
import torch
from pathlib import Path

DATA_BASE = Path("vilap_dataset")

ORI_SEQUENCE_IDX = [
    162, 127, 234, 93, 132, 58, 172, 136, 150, 149, 176, 148, 152,
    377, 400, 378, 379, 365, 397, 288, 361, 323, 454, 356, 389,
    70, 63, 105, 66, 107, 55, 65, 52, 53, 46,
    336, 296, 334, 293, 300, 276, 283, 282, 295, 285,
    168, 6, 197, 195, 5,
    48, 115, 220, 45, 4, 275, 440, 344, 278,
    33, 246, 161, 160, 159, 158, 157, 173, 133, 155, 154, 153, 145, 144, 163, 7,
    362, 398, 384, 385, 386, 387, 388, 466, 263, 249, 390, 373, 374, 380, 381, 382,
    61, 185, 40, 39, 37, 0, 267, 269, 270, 409, 291, 375, 321, 405, 314, 17, 84, 181, 91, 146,
    78, 191, 80, 81, 82, 13, 312, 311, 310, 415, 308, 324, 318, 402, 317, 14, 87, 178, 88, 95,
]


def load_clip(clip_key, data_base):
    dirname, vidname = clip_key.split("/")
    lm_dir = data_base / "05_landmark" / dirname / vidname

    npys = sorted(lm_dir.glob("*.npy"), key=lambda p: int(p.stem))
    frame_ids = [int(p.stem) for p in npys]

    pose_list, content_list = [], []

    for fid in frame_ids:
        d = np.load(lm_dir / f"{fid}.npy", allow_pickle=True).item()

        for key, pts, n in [
            ("pose_landmarks", pose_list, 74),
            ("content_landmarks", content_list, 57),
        ]:
            lm = sorted(d[key], key=lambda t: ORI_SEQUENCE_IDX.index(int(t[0])))

            arr = torch.zeros(2, n)
            arr[0] = torch.tensor([float(t[1]) for t in lm])
            arr[1] = torch.tensor([float(t[2]) for t in lm])

            pts.append(arr)

    all_pose = torch.stack(pose_list)        # shape: [N, 2, 74]
    all_content = torch.stack(content_list)  # shape: [N, 2, 57]

    mel = np.load(data_base / "06_audio" / dirname / vidname / "audio.npy")

    return all_pose, all_content, mel, frame_ids


pose, content, mel, fids = load_clip(
    "3p7dFrIx5bk/3p7dFrIx5bk_c0017",
    DATA_BASE,
)

print(
    f"Frames: {len(fids)}, "
    f"pose: {pose.shape}, "
    f"content: {content.shape}, "
    f"mel: {mel.shape}"
)
```

---

## Processing New Videos

To generate the dataset from raw videos, use the pipeline provided in [`scripts/process_vilap_data_pipeline.py`](../../scripts/process_vilap_data_pipeline.py).

```text
Step 1: Download or prepare raw .mp4 videos  →  02_clips/
Step 2: Detect and crop faces                →  03_face/
Step 3: Generate sketches, optional           →  04_sketch/
Step 4: Extract MediaPipe landmarks           →  05_landmark/
Step 5: Extract and resample audio            →  06_audio/
```

Requirements:

- Python 3.10.2
- `mediapipe`
- `librosa`
- `opencv-python`
- `ffmpeg`

For Mel-spectrogram extraction details consistent with IP-LAP, see [`scripts/preprocess_audio.py`](../../third_party/IP_LAP/preprocess/preprocess_audio.py).

---
<!-- 
## Model

The ViLAP model is a LoRA-based fine-tuned version of [IP-LAP](https://github.com/Weizhi-Zhong/IP_LAP) trained on the proposed Vietnamese dataset. Model checkpoints are released separately.

| Model | LMD ↓ | Mouth-MAE ↓ | Pearson-r ↑ |
|-------|------:|------------:|------------:|
| IP-LAP pretrained | 0.01386 | 0.01737 | 0.462 |
| ** LoRA Talk** | **0.01139** | **0.01357** | **0.522** |
 -->
---
<!-- 
## Citation

```bibtex
@misc{vilap2025,
  title = {ViLAP: Vietnamese Landmark-Audio-Pose Dataset for Talking Face Generation},
  year = {2025},
  note = {Hugging Face dataset},
}
```
 -->
---

## License

This dataset is released under the Creative Commons Attribution-NonCommercial 4.0 International License, CC BY-NC 4.0.

The original videos are sourced from publicly available YouTube content. The dataset is intended for research and non-commercial use only.