paulcho98's picture
Add TalkVid
ba5f085 verified

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 scripts/data_process/face_crop.sh 

2. face-info

Given the cropped face video directory, extract face-related parameters.

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 scripts/data_process/extract_audio_emb.sh 

Run

Before running the scripts, the expected dataset directory structure is as follows:

/path/to/dataset/    # TalkVid or HDTF; HDTF only contains videos/
β”œβ”€β”€ audios/
β”‚   β”œβ”€β”€ file1.m4a
β”‚   β”œβ”€β”€ file2.m4a
β”‚   └── ...
β”œβ”€β”€ videos/
β”‚   β”œβ”€β”€ file1.mp4
β”‚   β”œβ”€β”€ file2.mp4
β”‚   └── ...

To run the scripts:

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:

/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:

# 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 scripts/utils/create_data_json.py

Example output JSON format:

[
  {
    "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"
  },
  ...
]