Stochastic Adversarial Video Prediction
Switch branches/tags
Nothing to show
Clone or download

Stochastic Adversarial Video Prediction

[Project Page] [Paper]

TensorFlow implementation for stochastic adversarial video prediction. Given a sequence of initial frames, our model is able to predict future frames of various possible futures. For example, in the next two sequences, we show the ground truth sequence on the left and random predictions of our model on the right. Predicted frames are indicated by the yellow bar at the bottom. For more examples, visit the project page.

Stochastic Adversarial Video Prediction,
Alex X. Lee, Richard Zhang, Frederik Ebert, Pieter Abbeel, Chelsea Finn, Sergey Levine.
arXiv preprint arXiv:1804.01523, 2018.

Getting Started


  • Linux or macOS
  • Python 3


  • Clone this repo:
git clone -b master --single-branch
cd video_prediction
  • Install TensorFlow >= 1.9 and dependencies from
  • Install ffmpeg (optional, used to generate GIFs for visualization, e.g. in TensorBoard)
  • Install other dependencies
pip install -r requirements.txt

Note: in macOS, make sure that bash >= 4.0 is used (needed for associative arrays in script).

Use a Pre-trained Model

  • Download and preprocess a dataset (e.g. bair):
bash data/ bair
  • Download a pre-trained model (e.g. ours_savp) for the action-free version of that dataset (i.e. bair_action_free):
bash pretrained_models/ bair_action_free ours_savp
  • Sample predictions from the model:
CUDA_VISIBLE_DEVICES=0 python scripts/ --input_dir data/bair \
  --dataset_hparams sequence_length=30 \
  --checkpoint pretrained_models/bair_action_free/ours_savp \
  --mode test \
  --results_dir results_test_samples/bair_action_free
  • The predictions are saved as images and GIFs in results_test_samples/bair_action_free/ours_savp.
  • Evaluate predictions from the model using full-reference metrics:
CUDA_VISIBLE_DEVICES=0 python scripts/ --input_dir data/bair \
  --dataset_hparams sequence_length=30 \
  --checkpoint pretrained_models/bair_action_free/ours_savp \
  --mode test \
  --results_dir results_test/bair_action_free

Model Training

  • To train a model, download and preprocess a dataset (e.g. bair):
bash data/ bair
  • Train a model (e.g. our SAVP model on the BAIR action-free robot pushing dataset):
CUDA_VISIBLE_DEVICES=0 python scripts/ --input_dir data/bair --dataset bair \
  --model savp --model_hparams_dict hparams/bair_action_free/ours_savp/model_hparams.json \
  --output_dir logs/bair_action_free/ours_savp
  • To view training and validation information (e.g. loss plots, GIFs of predictions), run tensorboard --logdir logs/bair_action_free --port 6006 and open http://localhost:6006.
  • For multi-GPU training, set CUDA_VISIBLE_DEVICES to a comma-separated list of devices, e.g. CUDA_VISIBLE_DEVICES=0,1,2,3. To use the CPU, set CUDA_VISIBLE_DEVICES="".
  • See more training details for other datasets and models in scripts/


Download the datasets using the following script. These datasets are collected by other researchers. Please cite their papers if you use the data.

  • Download and preprocess the dataset.
bash data/ dataset_name

The dataset_name should be one of the following:

To use a different dataset, preprocess it into TFRecords files and define a class for it. See for an example where the original dataset is given as videos.

Note: the bair dataset is used for both the action-free and action-conditioned experiments. Set the hyperparameter use_state=True to use the action-conditioned version of the dataset.


  • Download the pre-trained models using the following script.
bash pretrained_models/ dataset_name model_name

The dataset_name should be one of the following: bair_action_free, kth, or bair. The model_name should be one of the available pre-trained models:

  • ours_savp: our complete model, trained with variational and adversarial losses. Also referred to as ours_vae_gan.

The following are ablations of our model:

  • ours_gan: trained with L1 and adversarial loss, with latent variables sampled from the prior at training time.
  • ours_vae: trained with L1 and KL loss.
  • ours_deterministic: trained with L1 loss, with no stochastic latent variables.

See pretrained_models/ for a complete list of available pre-trained models.

Model and Training Hyperparameters

The implementation is designed such that each video prediction model defines its architecture and training procedure, and include reasonable hyperparameters as defaults. Still, a few of the hyperparameters should be overriden for each variant of dataset and model. The hyperparameters used in our experiments are provided in hparams as JSON files, and they can be passed onto the training script with the --model_hparams_dict flag.


If you find this useful for your research, please use the following.

  title={Stochastic Adversarial Video Prediction},
  author={Alex X. Lee and Richard Zhang and Frederik Ebert and Pieter Abbeel and Chelsea Finn and Sergey Levine},
  journal={arXiv preprint arXiv:1804.01523},