In case you want to build your own training dataset from scratch, follow the instruction Building training dataset from scratch below. If you want to reproduce the OpenVidHD dataset used for model training, refer to the section Reproduction of the OpenVidHD training dataset at the bottom.
- Download the dataset into
{DATASET_PATH}and create a list of relative clip paths inclip_paths.txt.
An example of the dataset directory structure:
DATASET_PATH/
├── subfolder_0000/
│ ├── video_clip_00000.mp4
│ ├── video_clip_00001.mp4
│ ├── video_clip_00002.mp4
│ └── ...
├── subfolder_0001/
│ ├── video_clip_00000.mp4
│ ├── video_clip_00001.mp4
│ ├── video_clip_00002.mp4
│ └── ...
├── subfolder_0002/
│ └── ...
└── ...
An example of clip_paths.txt:
subfolder_0000/video_clip_00000.mp4
subfolder_0000/video_clip_00001.mp4
subfolder_0000/video_clip_00002.mp4
...
subfolder_0001/video_clip_00000.mp4
subfolder_0001/video_clip_00001.mp4
subfolder_0001/video_clip_00002.mp4
...
- Modify the
source_dirandvideo_listfields in the config used for therun_ffprobe.pyscript to match your data (see an example inconfigs/dataset/run_ffprobe.yaml) and run theffprobescript to collect clip metadata:
python run_ffprobe.py --config=configs/dataset/run_ffprobe.yaml
- Download job results and build
clip_meta.json:
python build_clip_meta.py <path to run_ffprobe results> clip_meta.json
- Download the pretrained SpyNet checkpoint as
me_spynet.pth.tar, matchingmodel.optic_flow.ckpt_pathinconfigs/dataset/run_optic_flow.yaml. Its SHA-256 checksum isa6f69e0f299ee9271b9e22c78472cf12be947d029b765bf2282f9bd03c5e35ab. Modifyclip_folderand verify that the path toclip_meta.jsonis correct in the config. Then, run optical flow calculation and collect per-clip statistics:
python run_optic_flow.py --config=configs/dataset/run_optic_flow.yaml
- Download the results of
run_optic_flow.py, i.e., optical flow and other statistics grouped by clip. Modify the config used for thebuild_frame_sequences.pyscript (see an example inconfigs/dataset/build_frame_sequences.yaml). In particular,sequence_lengthandn_sequencescan be changed to set the desired sequence length (number of frames per sequence) and the number of sequences to generate. Then, buildframe_sequences.csv:
python build_frame_sequences.py --config=configs/dataset/build_frame_sequences.yaml <path to collected statistics> frame_sequences.csv
- Modify the
source_dirandsequence_rangefields in the config used for theextract_frame_sequences.pyscript (see an example inconfigs/dataset/extract_frame_sequences.yaml). Run the sequence extraction job:
python extract_frame_sequences.py --config=configs/dataset/extract_frame_sequences.yaml
NB: Instead of running the script for the full sequence range, you may run several jobs in parallel, specifying a subset sequence_range in the config for each job, e.g., [0, 1000], [1000, 2000] and [2000, 3000] instead of [0, 3000].
- Build
description.json:
python build_dataset_description.py frame_sequences.csv description.json
-
Copy
description.jsonandframe_sequences.csvinto the output dataset folder. -
[Optional] Compute face segmentation masks, which are required for training with LPIPS-ROI loss. Set the
pathfield in the config for thecompute_segmentation_masks.pyscript. Run segmentation:
python compute_segmentation_masks.py --config=configs/dataset/compute_segmentation_masks.yaml
Copy masks to the output dataset folder. Besides, segmentation might have failed for some sequences. In this case, the script will produce failed_paths*.txt files and an updated description.json. Substitute the old description.json with the new one.
- Download a subset of OpenVidHD from here. Only parts 10-28 are required. Besides,
*_part_absubsets can be skipped. - The file openvidhd_parts_10-28_videos.txt can be used to verify that all necessary videos were downloaded at the previous step.
- Follow steps 6-9 from the instruction above. Make sure to specify openvidhd_60k64_frame_sequences.csv in
configs/dataset/extract_frame_sequences.yaml. The sub-index60k64refers to a dataset containing 60,000 sequences, each with 64 frames. In addition, you can generate a dataset using openvidhd_11k150_frame_sequences.csv or openvidhd_3k300_frame_sequences for training on longer sequences.