This is a pytorch implementation of DDIM. The original paper is here https://arxiv.org/abs/2010.02502 .
This code is almost identical to DDPM, see here: https://github.com/Alokia/diffusion-DDPM-pytorch
Almost all the parameters that can be modified are listed in the config.yml
file. You can modify the relevant parameters as needed, and then run the train.py
file to start training.
After training, run the generate.py
file to generate the results. These are the parameters of generate.py
:
-
-cp
: the path of checkpoint. -
--device
: device used.'cuda'
(default) or'cpu'
. -
--sampler
: sampler method, can be'ddpm'
(default) or'ddim'
. -
-bs
: how many images to generate at once. Default16
. -
--result_only
: whether to output only the generated results. DefaultFalse
. -
--interval
: extract an image every how many steps. Only valid without theresult_only
parameter. Default50
. -
--eta
: ddim parameter,$\eta$ in the paper. Default0.0
. -
--steps
: ddim sampling steps. Default100
. -
--method
: ddim sampling method. can be'linear'
(default) or'quadratic'
. -
--nrow
: how many images are displayed in a row. Only valid with theresult_only
parameter. Default4
. -
--show
: whether to display the result image. DefaultFalse
. -
-sp
: save path of the result image. DefaultNone
. -
--to_grayscale
: convert images to grayscale. DefaultFalse
.
python generate.py -cp "checkpoint/mnist.pth" -bs 16 --interval 3 --show -sp
"data/result/mnist_sampler.png" --sampler "ddim" --steps 50
python generate.py -cp "checkpoint/mnist.pth" -bs 256 --show -sp "data/result/mnist_result.png" --nrow 16 --result_only --sampler "ddim" --steps 50
- CIFAR10, click to download checkpoint
python generate.py -cp "checkpoint/cifar10.pth" -bs 16 --interval 10 --show -sp "data/result/cifar10_sampler.png" --sampler "ddim" --steps 200 --method "quadratic"
python generate.py -cp "checkpoint/cifar10.pth" -bs 256 --show -sp "data/result/cifar10_result.png" --nrow 16 --result_only --sampler "ddim" --steps 200 --method "quadratic"