File size: 3,152 Bytes
ba5f085 | 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 | # Data Processing Scripts
## 1. face-crop
Crop the input face video directory into 512x512 square frames with the face centered. This step can be skipped for the HDTF dataset, as the videos in that dataset already meet the requirement.
```bash
bash scripts/data_process/face_crop.sh
```
## 2. face-info
Given the cropped face video directory, extract face-related parameters.
```bash
bash scripts/data_process/extract_face_info.sh
```
## 3. audio-emb
Given a directory of videos with audio (HDTF) or a directory of audio files (TalkVid), extract audio features using wav2vec2.
```bash
bash scripts/data_process/extract_audio_emb.sh
```
# Run
Before running the scripts, the expected dataset directory structure is as follows:
```bash
/path/to/dataset/ # TalkVid or HDTF; HDTF only contains videos/
βββ audios/
β βββ file1.m4a
β βββ file2.m4a
β βββ ...
βββ videos/
β βββ file1.mp4
β βββ file2.mp4
β βββ ...
```
To run the scripts:
```bash
cd data_preprocess
# create conda env
bash env.sh
# download necessary hf-model-ckpts
bash download_hf.sh
# 1. Face cropping
bash scripts/data_process/face_crop.sh
# 2. Extract audio features
bash scripts/data_process/extract_audio_emb.sh
# 3. Extract face info
bash scripts/data_process/extract_face_info.sh
## Steps 1 and 2 can be executed in parallel. Step 3 requires the output of Step 1,
## so it can only start after Step 1 is completed (fully or partially).
```
After data processing is complete, the expected dataset directory structure is:
```bash
/path/to/dataset/
βββ audios/
β βββ 0000.m4a
β βββ 0001.m4a
β βββ ...
βββ new_face_info/
β βββ 0000.pt
β βββ 0001.pt
β βββ ...
βββ short_clip_aud_embeds/
β βββ 0000.pt
β βββ 0001.pt
β βββ ...
βββ videos/
β βββ 0000.mp4
β βββ 0001.mp4
β βββ ...
βββ videos-crop/
βββ 0000.mp4
βββ 0001.mp4
βββ ...
```
Sanity checks:
```bash
# 1. Check whether the number of frames in face-info and audio-emb matches those in videos-crop and videos
bash scripts/check/check_face_and_audio.sh
# 2. Check whether fps and frame count of videos-crop meet expectations (e.g., fps=24, frames=121)
python scripts/check/check_fps_frames.py
# 3. For finer-grained checks, see scripts/check/check_audio.txt
```
Create the JSON file for training:
```python
python scripts/utils/create_data_json.py
```
Example output JSON format:
```json
[
{
"video": "/data/TalkVid/videos-crop/videovideo-0F1owya2oo-scene20_scene2.mp4",
"face_info": "/data/TalkVid/new_face_info/videovideo-0F1owya2oo-scene20_scene2.pt",
"audio_embeds": "/data/TalkVid/short_clip_aud_embeds/videovideo-0F1owya2oo-scene20_scene2.pt"
},
{
"video": "/data/TalkVid/videos-crop/videovideo-0F1owya2oo-scene5_scene1.mp4",
"face_info": "/data/TalkVid/new_face_info/videovideo-0F1owya2oo-scene5_scene1.pt",
"audio_embeds": "/data/TalkVid/short_clip_aud_embeds/videovideo-0F1owya2oo-scene5_scene1.pt"
},
...
]
```
|