Training V2 - YuvalNirkin/fsgan GitHub Wiki
Data preparation
Download the IJB-C dataset (used in the paper) or alternatively any other source of high resolution videos will be fine as well.
The videos should be placed in a flat directory structure.
Run the following command to preprocess all the videos:
cd fsgan/preprocess
python preprocess_video.py <path/to/videos/directory>
This process is slow and can take several days. To speed up the preprocessing it is best to run on multiple GPUs. For example, preprocessing 1,000 videos on 2 GPUs:
# GPU 0
export CUDA_VISIBLE_DEVICES=0
python preprocess_video.py -i ":500" <path/to/videos/directory>
# GPU 1
export CUDA_VISIBLE_DEVICES=1
python preprocess_video.py -i "500:" <path/to/videos/directory>
Finally, provide a list of video files for the training and validation sets or generate them automatically using the following script:
python produce_train_val.py <path/to/videos/directory>
Training face reenactment
Edit the following variables in fsgan/experiments/reenactment/ijbc_msrunet_reenactment_attr_no_seg.py
configuration file:
root
- path to the videos datasettrain_dataset
andval_dataset
- adjust the paths to the split files relative toroot
.batch_size
- should be as large as possiple limited to the available GPUs memory.workers
- should be the number of available CPU cores.
To start the training run:
cd fsgan/experiments/reenactment
python ijbc_msrunet_reenactment_attr_no_seg.py
Training face inpainting
After obtaining a face reenactment model, it can be used in the training of the face completion model.
Edit the fsgan/experiments/swapping/ijbc_msrunet_inpainting.py
configuration files.
In addition to the variables mentioned for the face reenactment training, make sure reenactment_model
is set to the path of trained face reenactment model.
To start the training run:
cd fsgan/experiments/swapping
python ijbc_msrunet_inpainting.py
Training face blending
Like the face inpaintining training, this step should follow the face reenactment training.
Edit the fsgan/experiments/swapping/ijbc_msrunet_blending.py
configuration files.
In addition to the variables mentioned for the face reenactment training, make sure reenactment_model
is set to the path of trained face reenactment model.
To start the training run:
cd fsgan/experiments/swapping
python ijbc_msrunet_blending.py