PyTorch implementation for the paper Pseudo Numerical Methods for Diffusion Models on Manifolds

Related tags

Deep Learning PNDM
Overview

Pseudo Numerical Methods for Diffusion Models on Manifolds (PNDM)

PWC

This repo is the official PyTorch implementation for the paper Pseudo Numerical Methods for Diffusion Models on Manifolds

by Luping Liu, Yi Ren, Zhijie Lin, Zhou Zhao (Zhejiang University).

What does this code do?

This code is not only the official implementation for PNDM, but also a generic framework for DDIM-like models including:

Structure

This code contains three main objects including method, schedule and model. The following table shows the options supported by this code and the role of each object.

Object Option Role
method DDIM, S-PNDM, F-PNDM, FON, PF the numerical method used to generate samples
schedule linear, quad, cosine the schedule of adding noise to images
model DDIM, iDDPM, PF, PF_deep the neural network used to fit noise

All of them can be combined at will, so this code provide at least 5x3x4=60 choices to generate samples.

How to run the code

Dependencies

Run the following to install a subset of necessary python packages for our code.

pip install -r requirements.txt

Tip: mpi4py can make the generation process faster using multi-gpus. It is not necessary and can be removed freely.

Usage

Evaluate our models through main.py.

python main.py --runner sample --method F-PNDM --sample_speed 50 --device cuda --config ddim-cifar10.yml --image_path temp/results --model_path temp/models/ddim/ema_cifar10.ckpt
  • runner (train|sample): choose the mode of runner
  • method (DDIM|FON|S-PNDM|F-PNDM|PF): choose the numerical methods
  • sample_speed: control the total generation step
  • device (cpu|cuda:0): choose the device to use
  • config: choose the config file
  • image_path: choose the path to save images
  • model_path: choose the path of model

Train our models through main.py.

python main.py --runner train --device cuda --config ddim-cifar10.yml --train_path temp/train
  • train_path: choose the path to save training status

Checkpoints & statistics

All checkpoints of models and precalculated statistics for FID are provided in this Onedrive.

References

If you find the code useful for your research, please consider citing:

@inproceedings{liu2022pseudo,
    title={Pseudo Numerical Methods for Diffusion Models on Manifolds},
    author={Luping Liu and Yi Ren and Zhijie Lin and Zhou Zhao},
    booktitle={International Conference on Learning Representations},
    year={2022},
    url={https://openreview.net/forum?id=PlKWVd2yBkY}
}

This work is built upon some previous papers which might also interest you:

  • Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems 33 (2020): 6840-6851.
  • Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising Diffusion Implicit Models. International Conference on Learning Representations. 2020.
  • Yang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-Based Generative Modeling through Stochastic Differential Equations. International Conference on Learning Representations. 2020.
You might also like...
An unofficial implementation of "Unpaired Image Super-Resolution using Pseudo-Supervision." CVPR2020

UnpairedSR An unofficial implementation of "Unpaired Image Super-Resolution using Pseudo-Supervision." CVPR2020 turn RCAN(modified) -- xmodel(xilinx

Linear algebra python - Number of operations and problems in Linear Algebra and Numerical Linear Algebra

Linear algebra in python Number of operations and problems in Linear Algebra and

Pytorch Implementation of DiffSinger: Diffusion Acoustic Model for Singing Voice Synthesis (TTS Extension)
Pytorch Implementation of DiffSinger: Diffusion Acoustic Model for Singing Voice Synthesis (TTS Extension)

DiffSinger - PyTorch Implementation PyTorch implementation of DiffSinger: Diffusion Acoustic Model for Singing Voice Synthesis (TTS Extension). Status

Pytorch implementation of "Grad-TTS: A Diffusion Probabilistic Model for Text-to-Speech"

GradTTS Unofficial Pytorch implementation of "Grad-TTS: A Diffusion Probabilistic Model for Text-to-Speech" (arxiv) About this repo This is an unoffic

PyTorch Implementation of DiffGAN-TTS: High-Fidelity and Efficient Text-to-Speech with Denoising Diffusion GANs
PyTorch Implementation of DiffGAN-TTS: High-Fidelity and Efficient Text-to-Speech with Denoising Diffusion GANs

DiffGAN-TTS - PyTorch Implementation PyTorch implementation of DiffGAN-TTS: High

 Learning Energy-Based Models by Diffusion Recovery Likelihood
Learning Energy-Based Models by Diffusion Recovery Likelihood

Learning Energy-Based Models by Diffusion Recovery Likelihood Ruiqi Gao, Yang Song, Ben Poole, Ying Nian Wu, Diederik P. Kingma Paper: https://arxiv.o

This is the codebase for Diffusion Models Beat GANS on Image Synthesis.

This is the codebase for Diffusion Models Beat GANS on Image Synthesis.

Denoising Diffusion Probabilistic Models

Denoising Diffusion Probabilistic Models This repo contains code for DDPM training. Based on Denoising Diffusion Probabilistic Models, Improved Denois

Codebase for Diffusion Models Beat GANS on Image Synthesis.

Codebase for Diffusion Models Beat GANS on Image Synthesis.

Comments
  • Is the implementation for FON really 4-th order?

    Is the implementation for FON really 4-th order?

    Thanks for your inspiring work.

    I found the implementation of FON is confusing, which may not what claimed in the paper.

    Paper claims image

    However,

    def gen_fon(img, t, t_next, model, alphas_cump, ets):
        t_list = [t, (t + t_next) / 2.0, t_next]
        if len(ets) > 2:
            noise = model(img, t)
            img_next = transfer(img, t, t-1, noise, alphas_cump)
            delta = img_next - img
            ets.append(delta)
        else:
            noise = model(img, t_list[0])
            img_ = transfer(img, t, t - 1, noise, alphas_cump)
            delta_1 = img_ - img
            ets.append(delta_1)
    
            img_2 = img + delta_1 * (t - t_next).view(-1, 1, 1, 1) / 2.0
            noise = model(img_2, t_list[1])
            img_ = transfer(img, t, t - 1, noise, alphas_cump)
            delta_2 = img_ - img
    
            img_3 = img + delta_2 * (t - t_next).view(-1, 1, 1, 1) / 2.0
            noise = model(img_3, t_list[1])
            img_ = transfer(img, t, t - 1, noise, alphas_cump)
            delta_3 = img_ - img
    
            img_4 = img + delta_3 * (t - t_next).view(-1, 1, 1, 1)
            noise = model(img_4, t_list[2])
            img_ = transfer(img, t, t - 1, noise, alphas_cump)
            delta_4 = img_ - img
            delta = (1 / 6.0) * (delta_1 + 2*delta_2 + 2*delta_3 + delta_4)
    
        img_next = img + delta * (t - t_next).view(-1, 1, 1, 1)
        return img_next
    

    After len(ets) > 2, delta seems only use first order info?

    opened by qsh-zh 5
  • How do I generate a .ckpt file after training?

    How do I generate a .ckpt file after training?

    After training a model, how do I create a .ckpt file to use with the sample runner? The training loop writes out .pth files that seem almost correct, but they are slightly mismatched. After a bit of research, it appears that the model is saved with the nn.DataParallel module, but is loaded without it. Reference: https://discuss.pytorch.org/t/solved-keyerror-unexpected-key-module-encoder-embedding-weight-in-state-dict/1686/2

    opened by scottp100 1
  • Segmentation fault (11)

    Segmentation fault (11)

    Hey I am back, so i moved the program over to a google colab. Ran this command:

    !python main.py --runner sample --method F-PNDM --sample_speed 50 --device cuda --config ddim_cifar10.yml --image_path results --model_path models/ddim_cifar10.ckpt Everything was going fine and then ->

    image

    any advice?

    opened by DeepTitan 1
  • Add link to diffusers library

    Add link to diffusers library

    Hey :wave: from the diffusers team,

    Just wanted to ask if you are interested in adding a link to the diffusers library to your README. We're actively maintaining the PNDM pipeline and also enabled use cases to use PNDM with stable diffusion which might be interesting for readers of this repo.

    When integrating the PNDM we made sure to have 1-to-1 the same functionality - do you think such an addition could be useful for the readers of your repo? :-)

    Thanks a mille for open-sourcing your method - it has already powered millions of image generations for stable diffusion ;-)

    opened by patrickvonplaten 0
Owner
Luping Liu (刘路平)
Luping Liu (刘路平)
git《Pseudo-ISP: Learning Pseudo In-camera Signal Processing Pipeline from A Color Image Denoiser》(2021) GitHub: [fig5]

Pseudo-ISP: Learning Pseudo In-camera Signal Processing Pipeline from A Color Image Denoiser Abstract The success of deep denoisers on real-world colo

Yue Cao 51 Nov 22, 2022
Numerical Methods with Python, Numpy and Matplotlib

Numerical Bric-a-Brac Collections of numerical techniques with Python and standard computational packages (Numpy, SciPy, Numba, Matplotlib ...). Diffe

Vincent Bonnet 10 Dec 20, 2021
Pytorch implementation of the paper SPICE: Semantic Pseudo-labeling for Image Clustering

SPICE: Semantic Pseudo-labeling for Image Clustering By Chuang Niu and Ge Wang This is a Pytorch implementation of the paper. (In updating) SOTA on 5

Chuang Niu 154 Dec 15, 2022
A PyTorch-based open-source framework that provides methods for improving the weakly annotated data and allows researchers to efficiently develop and compare their own methods.

Knodle (Knowledge-supervised Deep Learning Framework) - a new framework for weak supervision with neural networks. It provides a modularization for se

null 93 Nov 6, 2022
This repository contains numerical implementation for the paper Intertemporal Pricing under Reference Effects: Integrating Reference Effects and Consumer Heterogeneity.

This repository contains numerical implementation for the paper Intertemporal Pricing under Reference Effects: Integrating Reference Effects and Consumer Heterogeneity.

Hansheng Jiang 6 Nov 18, 2022
Implementation of temporal pooling methods studied in [ICIP'20] A Comparative Evaluation Of Temporal Pooling Methods For Blind Video Quality Assessment

Implementation of temporal pooling methods studied in [ICIP'20] A Comparative Evaluation Of Temporal Pooling Methods For Blind Video Quality Assessment

Zhengzhong Tu 5 Sep 16, 2022
Official PyTorch implementation for FastDPM, a fast sampling algorithm for diffusion probabilistic models

Official PyTorch implementation for "On Fast Sampling of Diffusion Probabilistic Models". FastDPM generation on CIFAR-10, CelebA, and LSUN datasets. S

Zhifeng Kong 68 Dec 26, 2022
Implementation of Retrieval-Augmented Denoising Diffusion Probabilistic Models in Pytorch

Retrieval-Augmented Denoising Diffusion Probabilistic Models (wip) Implementation of Retrieval-Augmented Denoising Diffusion Probabilistic Models in P

Phil Wang 55 Jan 1, 2023
aka "Bayesian Methods for Hackers": An introduction to Bayesian methods + probabilistic programming with a computation/understanding-first, mathematics-second point of view. All in pure Python ;)

Bayesian Methods for Hackers Using Python and PyMC The Bayesian method is the natural approach to inference, yet it is hidden from readers behind chap

Cameron Davidson-Pilon 25.1k Jan 2, 2023
This is an unofficial PyTorch implementation of Meta Pseudo Labels

This is an unofficial PyTorch implementation of Meta Pseudo Labels. The official Tensorflow implementation is here.

Jungdae Kim 320 Jan 8, 2023