Home

Awesome

Poisson Flow Generative Models

Pytorch implementation of the NeurIPS 2022 paper Poisson Flow Generative Models,

by Yilun Xu*, Ziming Liu*, Max Tegmark, Tommi S. Jaakkola

[Slide]

Note: The method has been extended by the subsequent work PFGM++: Unlocking the Potential of Physics-Inspired Generative Models (code) with the following improvements:

😇 Improvements over PFGM / Diffusion Models:

Hence, we recommend the PFGM++ framework for new projects.


We propose a new Poisson flow generative model (PFGM) that maps a uniform distribution on a high-dimensional hemisphere into any data distribution. We interpret the data points as electrical charges on the $z=0$ hyperplane in a space augmented with an additional dimension $z$, generating a high-dimensional electric field (the gradient of the solution to Poisson equation). We prove that if these charges flow upward along electric field lines, their initial distribution in the $z=0$ plane transforms into a distribution on the hemisphere of radius $r$ that becomes uniform in the $r \to\infty$ limit. To learn the bijective transformation, we estimate the normalized field {in the augmented space}. For sampling, we devise a backward ODE that is anchored by the physically meaningful additional dimension: the samples hit the (unaugmented) data manifold when the $z$ reaches zero.

schematic

Experimentally, PFGM achieves current state-of-the-art performance among the normalizing flow models on CIFAR-10, with an Inception score of 9.68 and a FID score of 2.35. It also performs on par with the state-of-the-art SDE approaches (e.g., score-based SDEs or Diffusion models) while offering 10x to 20x acceleration on image generation tasks. Additionally, PFGM appears more tolerant of estimation errors on a weaker network architecture and robust to the step size in the Euler method, and capable of scale-up to higher resolution datasets.


Acknowledgement: Our implementation relies on the repo https://github.com/yang-song/score_sde_pytorch.

Dependencies

We provide two solutions to install a subset of necessary python packages for our code. Please find the best fit for you.

  1. The old dependency in repo https://github.com/yang-song/score_sde_pytorch
pip install -r requirements_old.txt
  1. Our dependency (Python 3.9.12, CUDA Version 11.6)
pip install -r requirements.txt

Usage

Train and evaluate our models through main.py.

python3 main.py:
  --config: Training configuration.
  --eval_folder: The folder name for storing evaluation results
    (default: 'eval')
  --mode: <train|eval>: Running mode: train or eval
  --workdir: Working directory

For example, to train a new PFGM w/ DDPM++ model on CIFAR-10 dataset, one could execute

python3 main.py --config ./configs/poisson/cifar10_ddpmpp.py --mode train \
--workdir poisson_ddpmpp

Tips

Checkpoints

Please place the pretrained checkpoints under the directory workdir/checkpoints, e.g., cifar10_ddpmpp/checkpoints.

To generate and evaluate the FID/IS of (10k) samples of the PFGM w/ DDPM++ model, you could execute:

python3 main.py --config ./configs/poisson/cifar10_ddpmpp.py --mode eval \ 
--workdir cifar10_ddpmpp --config.eval.enable_sampling --config.eval.num_samples 10000

To only generate and visualize 100 samples of the PFGM w/ DDPM++ model, you could execute:

python3 main.py --config ./configs/poisson/cifar10_ddpmpp.py --mode eval \ 
--workdir cifar10_ddpmpp --config.eval.enable_sampling --config.eval.save_images --config.eval.batch_size 100

The samples will be saved to cifar10_ddpmpp/eval/ode_images_{ckpt}.png.

All checkpoints are provided in this Google drive folder.

DatasetCheckpoint pathInvertible?ISFIDNFE (RK45)
CIFAR-10poisson/cifar10_ddpmpp/:heavy_check_mark:9.652.48~104
CIFAR-10poisson/cifar10_ddpmpp_deep/:heavy_check_mark:9.682.35~110
LSUN bedroom $256^2$poisson/bedroom_ddpmpp/:heavy_check_mark:-13.66~122
CelebA $64^2$poisson/celeba_ddpmpp/:heavy_check_mark:-3.68~110

FID statistics

Please find the statistics for FID scores in the following links:

CIFAR-10, CelebA 64, LSUN bedroom 256

<center><img src="assets/pfgm_cat.gif" width="750" height="250"/></center>