
Pytorch implementation for few-shot photorealistic video-to-video translation. It can be used for generating human motions from poses, synthesizing people talking from edge maps, or turning semantic label maps into photo-realistic videos. The core of video-to-video translation is image-to-image translation. Some of our work in that space can be found in pix2pixHD and SPADE.
Few-shot Video-to-Video Synthesis
Ting-Chun Wang, Ming-Yu Liu, Andrew Tao, Guilin Liu, Jan Kautz, Bryan Catanzaro
NVIDIA Corporation
In Neural Information Processing Systems (NeurIPS) 2019
Copyright (C) 2019 NVIDIA Corporation. All rights reserved.
This work is made available under the Nvidia Source Code License (1-Way Commercial). To view a copy of this license, visit https://nvlabs.github.io/few-shot-vid2vid/License.txt
The code is released for academic research use only. For business inquiries, please visit our website and submit the form: NVIDIA Research Licensing


[Note] This repo is now deprecated. Please refer to the new Imaginaire repo: https://github.com/NVlabs/imaginaire.
pip install dominate requests
pip install dlib
git clone https://github.com/NVlabs/few-shot-vid2vid
cd few-shot-vid2vid
data/preprocess. Please note that the copyright of the dataset belongs to the original owners.datasets folder in the same way the example images are provided.[Note] This repo is now deprecated. Please refer to the new Imaginaire repo: https://github.com/NVlabs/imaginaire.
- First, compile a snapshot of FlowNet2 by running python scripts/download_flownet2.py.
- Please first download example datasets by running python scripts/download_datasets.py.
- The following scripts are examples of using one GPU. For multi-GPU training, simply increase the batch sizes.
bash ./scripts/pose/train_g1.sh)
bash
python train.py --name pose --dataset_mode fewshot_pose --adaptive_spade --warp_ref --spade_combine --remove_face_labels --add_face_D --niter_single 100 --niter 200 --batchSize 2bash ./scripts/face/train_g1.sh)
bash
python train.py --name face --dataset_mode fewshot_face --adaptive_spade --warp_ref --spade_combine --batchSize 8bash ./scripts/street/train_g1.sh)
bash
python train.py --name street --dataset_mode fewshot_street --adaptive_spade --loadSize 512 --fineSize 512 --batchSize 6--label_nc N during both training and testing.--input_nc N where N is the number of input channels (The default is 3 for RGB images).scale_width, which will scale the width of all training images to opt.loadSize while keeping the aspect ratio. If you want a different setting, please change it by using the --resize_or_crop option../results/. Due to privacy concerns, the pretrained models are not released.To test the trained model (bash ./scripts/pose/test.sh):
bash
python test.py --name pose --dataset_mode fewshot_pose --adaptive_spade --warp_ref --spade_combine --remove_face_labels --finetune --seq_path [PATH_TO_SEQ] --ref_img_path [PATH_TO_REF_IMG]
Faces
To test the model (bash ./scripts/face/test.sh):
bash
python test.py --name face --dataset_mode fewshot_face --adaptive_spade --warp_ref --spade_combine --seq_path [PATH_TO_SEQ] --ref_img_path [PATH_TO_REF_IMG]
Street
bash ./scripts/street/test.sh):
bash
python test.py --name street --dataset_mode fewshot_street --adaptive_spade --loadSize 512 --fineSize 512 --seq_path [PATH_TO_SEQ]--ref_img_path [PATH_TO_REF_IMG]Training schedule: after switching to using SPADE, the network now consists of two sub-networks: one for single image generation (the SPADE generator) and the flow estimation network. By default, the training will start with training the single frame generator only (i.e. n_frames_total = 1) for niter_single epochs. After that, the network will start to train the flow network to generate videos, and temporal losses are introduced. Similar to vid2vid, we double the training sequence length for every niter_step epochs after starting training videos.
Important flags regarding network arch:
adaptive_spade: adaptively generate network weights for SPADE modules.no_adaptive_embed: do not dynamically generate weights for the label embedding network.n_adaptive_layers: number of adaptive layers in the generator.warp_ref: add an additional flow network to warp the reference image to the current frame and combine with it.spade_combine: instead of linearly blending hallucinated and warped frames to generate the final frame, use warped frame as a guidance image in an additional SPADE module during the synthesis process.
Important flags regarding training:
n_frames_G: the number of input frames to feed into the generator network; i.e., n_frames_G - 1 is the number of frames we look into the past.n_frames_total: the total number of frames in a sequence we want to train with. We gradually increase this number during training.niter_single: the number of epochs we train the single frame generator before starting training videos.niter_step: for how many epochs do we double n_frames_total. The default is 10. batchSize: the number of training batches. If it is not divisible by number of GPUs, the first GPU (which is usually more memory heavy) will do fewer batches.
For other flags, please see options/train_options.py and options/base_options.py for all the training flags; see options/test_options.py and options/base_options.py for all the test flags.
Additional flags for pose examples:
remove_face_labels: remove densepose results for face, so the network can get more robust during inference on different subjects.basic_point_only: if specified, only use basic joint keypoints for OpenPose output, without using any hand or face keypoints.add_face_D: add an additional discriminator that only works on the face region. refine_face: add an additional network to refine the face region.
Additional flags for face examples:
no_upper_face: by default, we add artificial edges for the upper part of face by symmetry. This flag disables it.If you find this useful for your research, please cite the following paper.
@inproceedings{wang2019fewshotvid2vid,
author = {Ting-Chun Wang and Ming-Yu Liu and Andrew Tao
and Guilin Liu and Jan Kautz and Bryan Catanzaro},
title = {Few-shot Video-to-Video Synthesis},
booktitle = {Conference on Neural Information Processing Systems (NeurIPS)},
year = {2019},
}
We thank Karan Sapra for generating the segmentation maps for us.
$ claude mcp add few-shot-vid2vid \
-- python -m otcore.mcp_server <graph>