Karras et al. (2022) diffusion models for PyTorch
Project description
k-diffusion
An implementation of Elucidating the Design Space of Diffusion-Based Generative Models (Karras et al., 2022) for PyTorch. The patching method in Improving Diffusion Model Efficiency Through Patching is implemented as well.
Installation
k-diffusion
can be installed via PyPI (pip install k-diffusion
) but it will not include training and inference scripts, only library code that others can depend on. To run the training and inference scripts, clone this repository and run pip install -e <path to repository>
.
Training:
To train models:
$ ./train.py --config CONFIG_FILE --name RUN_NAME
For instance, to train a model on MNIST:
$ ./train.py --config configs/config_mnist.json --name RUN_NAME
The configuration file allows you to specify the dataset type. Currently supported types are "imagefolder"
(finds all images in that folder and its subfolders, recursively), "cifar10"
(CIFAR-10), and "mnist"
(MNIST). "huggingface"
Hugging Face Datasets is also supported.
Multi-GPU and multi-node training is supported with Hugging Face Accelerate. You can configure Accelerate by running:
$ accelerate config
on all nodes, then running:
$ accelerate launch train.py --config CONFIG_FILE --name RUN_NAME
on all nodes.
Enhancements/additional features:
-
k-diffusion supports an experimental model output type, an isotropic Gaussian, which seems to have a lower gradient noise scale and to train faster than Karras et al. (2022) diffusion models.
-
k-diffusion has wrappers for v-diffusion-pytorch, OpenAI diffusion, and CompVis diffusion models allowing them to be used with its samplers and ODE/SDE.
-
k-diffusion models support progressive growing.
-
k-diffusion implements DPM-Solver, which produces higher quality samples at the same number of function evalutions as Karras Algorithm 2, as well as supporting adaptive step size control. DPM-Solver++(2S) and (2M) are implemented now too for improved quality with low numbers of steps.
-
k-diffusion supports CLIP guided sampling from unconditional diffusion models (see
sample_clip_guided.py
). -
k-diffusion supports log likelihood calculation (not a variational lower bound) for native models and all wrapped models.
-
k-diffusion can calculate, during training, the FID and KID vs the training set.
-
k-diffusion can calculate, during training, the gradient noise scale (1 / SNR), from An Empirical Model of Large-Batch Training, https://arxiv.org/abs/1812.06162).
To do:
-
Anything except unconditional image diffusion models
-
Latent diffusion
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file k-diffusion-0.0.10.tar.gz
.
File metadata
- Download URL: k-diffusion-0.0.10.tar.gz
- Upload date:
- Size: 22.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84c859f03b945ed4d37389e457895c8b9645c2b916e4580ea9690ebeeac6b791 |
|
MD5 | 02b9edec8f1df94d3709c726331bc11a |
|
BLAKE2b-256 | 2f41e0620f3c28faa76669f13e99d7ca95e62769bcf66125c3e540d79d55d280 |
File details
Details for the file k_diffusion-0.0.10-py3-none-any.whl
.
File metadata
- Download URL: k_diffusion-0.0.10-py3-none-any.whl
- Upload date:
- Size: 24.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2563d2fd6ecae7261b3186bd7b0c80722aa7c7d0f2b937bc74c0e094d486ddbb |
|
MD5 | ff6141722b186ce7c0ec254cdbe676c5 |
|
BLAKE2b-256 | 85db58150c9fd5ae9f33d42987fad793c883109826ae1299c5ffc96d7c61659f |