Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implementation of Denoising Diffusion Probabilistic Model in Pytorch

License

NotificationsYou must be signed in to change notification settings

lilisierrayu/denoising-diffusion-pytorch

 
 

Repository files navigation

Denoising Diffusion Probabilistic Model, in Pytorch

Implementation ofDenoising Diffusion Probabilistic Model in Pytorch. It is a new approach to generative modeling that mayhave the potential to rival GANs. It uses denoising score matching to estimate the gradient of the data distribution, followed by Langevin sampling to sample from the true distribution.

This implementation was transcribed from the official Tensorflow versionhere

PyPI version

Install

$ pip install denoising_diffusion_pytorch

Usage

importtorchfromdenoising_diffusion_pytorchimportUnet,GaussianDiffusionmodel=Unet(dim=64,dim_mults= (1,2,4,8))diffusion=GaussianDiffusion(model,image_size=128,timesteps=1000,# number of stepsloss_type='l1'# L1 or L2)training_images=torch.randn(8,3,128,128)# your images need to be normalized from a range of -1 to +1loss=diffusion(training_images)loss.backward()# after a lot of trainingsampled_images=diffusion.sample(batch_size=4)sampled_images.shape# (4, 3, 128, 128)

Or, if you simply want to pass in a folder name and the desired image dimensions, you can use theTrainer class to easily train a model.

fromdenoising_diffusion_pytorchimportUnet,GaussianDiffusion,Trainermodel=Unet(dim=64,dim_mults= (1,2,4,8)).cuda()diffusion=GaussianDiffusion(model,image_size=128,timesteps=1000,# number of stepsloss_type='l1'# L1 or L2).cuda()trainer=Trainer(diffusion,'path/to/your/images',train_batch_size=32,train_lr=2e-5,train_num_steps=700000,# total training stepsgradient_accumulate_every=2,# gradient accumulation stepsema_decay=0.995,# exponential moving average decayamp=True# turn on mixed precision)trainer.train()

Samples and model checkpoints will be logged to./results periodically

Citations

@inproceedings{NEURIPS2020_4c5bcfec,author      ={Ho, Jonathan and Jain, Ajay and Abbeel, Pieter},booktitle   ={Advances in Neural Information Processing Systems},editor      ={H. Larochelle and M. Ranzato and R. Hadsell and M.F. Balcan and H. Lin},pages       ={6840--6851},publisher   ={Curran Associates, Inc.},title       ={Denoising Diffusion Probabilistic Models},url         ={https://proceedings.neurips.cc/paper/2020/file/4c5bcfec8584af0d967f1ab10179ca4b-Paper.pdf},volume      ={33},year        ={2020}}
@InProceedings{pmlr-v139-nichol21a,title       ={Improved Denoising Diffusion Probabilistic Models},author      ={Nichol, Alexander Quinn and Dhariwal, Prafulla},booktitle   ={Proceedings of the 38th International Conference on Machine Learning},pages       ={8162--8171},year        ={2021},editor      ={Meila, Marina and Zhang, Tong},volume      ={139},series      ={Proceedings of Machine Learning Research},month       ={18--24 Jul},publisher   ={PMLR},pdf         ={http://proceedings.mlr.press/v139/nichol21a/nichol21a.pdf},url         ={https://proceedings.mlr.press/v139/nichol21a.html},}

About

Implementation of Denoising Diffusion Probabilistic Model in Pytorch

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python100.0%

[8]ページ先頭

©2009-2025 Movatter.jp