All Projects → kpandey008 → DiffuseVAE

kpandey008 / DiffuseVAE

Licence: MIT License
A combination of VAE's and Diffusion Models for efficient, controllable and high-fidelity generation from low-dimensional latents

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to DiffuseVAE

generative deep learning
Generative Deep Learning Sessions led by Anugraha Sinha (Machine Learning Tokyo)
Stars: ✭ 24 (-70.37%)
Mutual labels:  generative-model, vae
Vae For Image Generation
Implemented Variational Autoencoder generative model in Keras for image generation and its latent space visualization on MNIST and CIFAR10 datasets
Stars: ✭ 87 (+7.41%)
Mutual labels:  generative-model, vae
Vae protein function
Protein function prediction using a variational autoencoder
Stars: ✭ 57 (-29.63%)
Mutual labels:  generative-model, vae
Sentence Vae
PyTorch Re-Implementation of "Generating Sentences from a Continuous Space" by Bowman et al 2015 https://arxiv.org/abs/1511.06349
Stars: ✭ 462 (+470.37%)
Mutual labels:  generative-model, vae
vqvae-2
PyTorch implementation of VQ-VAE-2 from "Generating Diverse High-Fidelity Images with VQ-VAE-2"
Stars: ✭ 65 (-19.75%)
Mutual labels:  generative-model, vae
Generative Models
Collection of generative models, e.g. GAN, VAE in Pytorch and Tensorflow.
Stars: ✭ 6,701 (+8172.84%)
Mutual labels:  generative-model, vae
Attend infer repeat
A Tensorfflow implementation of Attend, Infer, Repeat
Stars: ✭ 82 (+1.23%)
Mutual labels:  generative-model, vae
Dfc Vae
Variational Autoencoder trained by Feature Perceputal Loss
Stars: ✭ 74 (-8.64%)
Mutual labels:  generative-model, vae
score sde pytorch
PyTorch implementation for Score-Based Generative Modeling through Stochastic Differential Equations (ICLR 2021, Oral)
Stars: ✭ 755 (+832.1%)
Mutual labels:  diffusion-models, controllable-generation
InpaintNet
Code accompanying ISMIR'19 paper titled "Learning to Traverse Latent Spaces for Musical Score Inpaintning"
Stars: ✭ 48 (-40.74%)
Mutual labels:  generative-model, vae
Awesome Vaes
A curated list of awesome work on VAEs, disentanglement, representation learning, and generative models.
Stars: ✭ 418 (+416.05%)
Mutual labels:  generative-model, vae
char-VAE
Inspired by the neural style algorithm in the computer vision field, we propose a high-level language model with the aim of adapting the linguistic style.
Stars: ✭ 18 (-77.78%)
Mutual labels:  generative-model, vae
Tensorflow Generative Model Collections
Collection of generative models in Tensorflow
Stars: ✭ 3,785 (+4572.84%)
Mutual labels:  generative-model, vae
Pytorch Mnist Vae
Stars: ✭ 32 (-60.49%)
Mutual labels:  generative-model, vae
srVAE
VAE with RealNVP prior and Super-Resolution VAE in PyTorch. Code release for https://arxiv.org/abs/2006.05218.
Stars: ✭ 56 (-30.86%)
Mutual labels:  generative-model, vae
Tf Vqvae
Tensorflow Implementation of the paper [Neural Discrete Representation Learning](https://arxiv.org/abs/1711.00937) (VQ-VAE).
Stars: ✭ 226 (+179.01%)
Mutual labels:  generative-model, vae
Diffusion-Models-Seminar
No description or website provided.
Stars: ✭ 75 (-7.41%)
Mutual labels:  generative-model, diffusion-models
style-vae
Implementation of VAE and Style-GAN Architecture Achieving State of the Art Reconstruction
Stars: ✭ 25 (-69.14%)
Mutual labels:  generative-model, vae
MISE
Multimodal Image Synthesis and Editing: A Survey
Stars: ✭ 214 (+164.2%)
Mutual labels:  diffusion-models
VAE-Gumbel-Softmax
An implementation of a Variational-Autoencoder using the Gumbel-Softmax reparametrization trick in TensorFlow (tested on r1.5 CPU and GPU) in ICLR 2017.
Stars: ✭ 66 (-18.52%)
Mutual labels:  vae

DiffuseVAE: Efficient, Controllable and High-Fidelity Generation from Low-Dimensional Latents

This repo contains the official implementation of the paper: DiffuseVAE: Efficient, Controllable and High-Fidelity Generation from Low-Dimensional Latents by Kushagra Pandey, Avideep Mukherjee, Piyush Rai, Abhishek Kumar


Overview

DiffuseVAE is a novel generative framework that integrates a standard VAE within a diffusion model by conditioning the diffusion model samples on the VAE generated reconstructions. The resulting model can significantly improve upon the blurry samples generated from a standard VAE while at the same time equipping diffusion models with the low-dimensional VAE inferred latent code which can be used for downstream tasks like controllable synthesis and image attribute manipulation. In short, DiffuseVAE presents a generative model which combines the benefits of both VAEs and Diffusion models.

architecture!

Our core contributions are as follows:

  1. We propose a generic DiffuseVAE conditioning framework and show that our framework can be reduced to a simple generator-refiner framework in which blurry samples generated from a VAE are refined using a conditional DDPM formulation.

  2. Controllable synthesis from a low-dimensional latent using diffusion models.

  3. Sampling speedups: We show that DiffuseVAE inherently requires fewer reverse diffusion sampling steps during inference compared to the unconditional DDPM model. Furthermore we also present a DiffuseVAE formulation conditioned on continuous noise as proposed in WaveGrad and show that we can generate plausible image samples in as few as 10 reverse sampling steps.

  4. State-of-the-art synthesis: DiffuseVAE achieves a FID score of 8.72 on CIFAR-10 and 4.76 on CelebA-64, thus outperforming (Hierarchical) VAE-based methods.

  5. Generalization to Downstream tasks: DiffuseVAE exhibits out-of-the-box generalization to downstream tasks like image super-resolution and denoising.

High res samples!


Code overview

This repo uses PyTorch Lightning for training and Hydra for config management so basic familiarity with both these tools is expected. Please clone the repo with DiffuseVAE as the working directory for any downstream tasks like setting up the dependencies, training and inference.

Setting up the dependencies

We use pipenv for a project-level dependency management. Simply install pipenv and run the following command:

pipenv install

Training

A sample command to train DiffuseVAE is as follows:

python main/train_ddpm.py +dataset=celeba64/train \
                     dataset.ddpm.data.root='/path/to/celeba64/reconstructions/dir/' \
                     dataset.ddpm.data.name='recons' \
                     dataset.ddpm.data.hflip=True \
                     dataset.ddpm.data.norm=True \
                     dataset.ddpm.training.type='form1' \
                     dataset.ddpm.training.batch_size=32 \
                     dataset.ddpm.training.device=\'gpu:1\' \
                     dataset.ddpm.training.results_dir=\'/data1/kushagrap20/celeba64_10thJan_form1\' \
                     dataset.ddpm.training.workers=2 \
                     dataset.ddpm.training.chkpt_prefix='celeba64_10thJan_form1'

For training the noise-conditioned version of DiffuseVAE, simply switch to the vaedm-noise-cond branch using git checkout vaedm-noise-cond and run the same command as above.

Inference

A sample command to perform sample generation using a pretrained DiffuseVAE model is as follows:

python main/eval/ddpm/sample_cond.py +dataset=celebamaskhq128/test \
                        dataset.ddpm.data.norm=True \
                        dataset.ddpm.evaluation.seed=0 \
                        dataset.ddpm.evaluation.sample_prefix='gpu_0' \
                        dataset.ddpm.evaluation.device=\'gpu:0\' \
                        dataset.ddpm.evaluation.chkpt_path=\'/path/to/pretrained/ddpm/checkpoint.pt\' \
                        dataset.ddpm.evaluation.type='form1' \
                        dataset.ddpm.evaluation.temp=1.0 \
                        dataset.ddpm.evaluation.batch_size=64 \
                        dataset.ddpm.evaluation.save_path=\'/path/where/to/save/samples/\' \
                        dataset.ddpm.evaluation.n_samples=4 \
                        dataset.ddpm.evaluation.n_steps=1000 \
                        dataset.ddpm.evaluation.save_vae=True \
                        dataset.ddpm.evaluation.workers=1 \
                        dataset.vae.evaluation.chkpt_path=\'/path/to/pretrained/vae/checkpoint.pt\'

For sample generation from the noise-conditioned version of DiffuseVAE, simply switch to the vaedm-noise-cond branch using git checkout vaedm-noise-cond and run the following command.

python main/eval/ddpm/sample_cond.py +dataset=celebamaskhq128/test \
                        dataset.ddpm.data.norm=True \
                        dataset.ddpm.model.beta1=1e-6 \
                        dataset.ddpm.model.beta2=0.6 \
                        dataset.ddpm.model.n_timesteps=10 \
                        dataset.ddpm.evaluation.seed=0 \
                        dataset.ddpm.evaluation.sample_prefix='gpu_1' \
                        dataset.ddpm.evaluation.device=\'gpu:0,1\' \
                        dataset.ddpm.evaluation.chkpt_path=\'/path/to/pretrained/ddpm/checkpoint.pt\' \
                        dataset.ddpm.evaluation.type='form1' \
                        dataset.ddpm.evaluation.temp=1.0 \
                        dataset.ddpm.evaluation.batch_size=16 \
                        dataset.ddpm.evaluation.save_path=\'/path/where/to/save/samples/\' \
                        dataset.ddpm.evaluation.n_samples=64 \
                        dataset.ddpm.evaluation.n_steps=10 \
                        dataset.ddpm.evaluation.save_vae=True \
                        dataset.ddpm.evaluation.workers=1 \
                        dataset.ddpm.evaluation.persistent_buffers=False \
                        dataset.vae.evaluation.chkpt_path=\'/path/to/pretrained/vae/checkpoint.pt\'

Pretrained checkpoints

NOTE: We are currently organizing all pretrained checkpoints and will add the links to download the checkpoints soon.

Citing

To cite DiffuseVAE please use the following BibTEX entries:

@misc{pandey2022diffusevae,
      title={DiffuseVAE: Efficient, Controllable and High-Fidelity Generation from Low-Dimensional Latents}, 
      author={Kushagra Pandey and Avideep Mukherjee and Piyush Rai and Abhishek Kumar},
      year={2022},
      eprint={2201.00308},
      archivePrefix={arXiv},
      primaryClass={cs.LG}
}
@inproceedings{
pandey2021vaes,
title={{VAE}s meet Diffusion Models: Efficient and High-Fidelity Generation},
author={Kushagra Pandey and Avideep Mukherjee and Piyush Rai and Abhishek Kumar},
booktitle={NeurIPS 2021 Workshop on Deep Generative Models and Downstream Applications},
year={2021},
url={https://openreview.net/forum?id=-J8dM4ed_92}
}

Since our model uses diffusion models please consider citing the original Diffusion model, DDPM and VAE papers.

Contact

Kushagra Pandey (@kpandey008)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].