flaxdiff 0.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,362 @@
1
+ Metadata-Version: 2.4
2
+ Name: flaxdiff
3
+ Version: 0.0.0
4
+ Summary: A versatile and easy to understand Diffusion library
5
+ Author-email: Ashish Kumar Singh <ashishkmr472@gmail.com>
6
+ License-Expression: MIT
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: flax>=0.8.4
9
+ Requires-Dist: jax>=0.4.28
10
+ Requires-Dist: optax>=0.2.2
11
+ Requires-Dist: orbax
12
+ Requires-Dist: numpy
13
+ Requires-Dist: clu
14
+ Requires-Dist: einops
15
+ Requires-Dist: tqdm
16
+ Requires-Dist: grain
17
+ Requires-Dist: termcolor
18
+ Requires-Dist: augmax
19
+ Requires-Dist: albumentations
20
+ Requires-Dist: rich
21
+ Requires-Dist: python-dotenv
22
+
23
+ # ![](images/logo.jpeg "FlaxDiff")
24
+
25
+ **This project is partially supported by [Google TPU Research Cloud](https://sites.research.google/trc/about/). I would like to thank the Google Cloud TPU team for providing me with the resources to train the bigger text-conditional models in multi-host distributed settings.**
26
+
27
+ ## A Versatile and simple Diffusion Library
28
+
29
+ In recent years, diffusion and score-based multi-step models have revolutionized the generative AI domain. However, the latest research in this field has become highly math-intensive, making it challenging to understand how state-of-the-art diffusion models work and generate such impressive images. Replicating this research in code can be daunting.
30
+
31
+ FlaxDiff is a library of tools (schedulers, samplers, models, etc.) designed and implemented in an easy-to-understand way. The focus is on understandability and readability over performance. I started this project as a hobby to familiarize myself with Flax and Jax and to learn about diffusion and the latest research in generative AI.
32
+
33
+ I initially started this project in Keras, being familiar with TensorFlow 2.0, but transitioned to Flax, powered by Jax, for its performance and ease of use. The old notebooks and models, including my first Flax models, are also provided.
34
+
35
+ The `Diffusion_flax_linen.ipynb` notebook is my main workspace for experiments. Several checkpoints are uploaded to the `pretrained` folder along with a copy of the working notebook associated with each checkpoint. *You may need to copy the notebook to the working root for it to function properly.*
36
+
37
+ ## Example Notebooks from scratch
38
+
39
+ In the `example notebooks` folder, you will find comprehensive notebooks for various diffusion techniques, written entirely from scratch and are independent of the FlaxDiff library. Each notebook includes detailed explanations of the underlying mathematics and concepts, making them invaluable resources for learning and understanding diffusion models.
40
+
41
+ ### Available Notebooks and Resources
42
+
43
+ - **[Diffusion explained (nbviewer link)](https://nbviewer.org/github/AshishKumar4/FlaxDiff/blob/main/tutorial%20notebooks/simple%20diffusion%20flax.ipynb) [(local link)](tutorial%20notebooks/simple%20diffusion%20flax.ipynb)**
44
+
45
+ - **WORK IN PROGRESS** An in-depth exploration of the concept of Diffusion based generative models, DDPM (Denoising Diffusion Probabilistic Models), DDIM (Denoising Diffusion Implicit Models), and the SDE/ODE generalizations of diffusion, with step-by-step explainations and code.
46
+
47
+ <a target="_blank" href="https://colab.research.google.com/github/AshishKumar4/FlaxDiff/blob/main/tutorial%20notebooks/simple%20diffusion%20flax.ipynb">
48
+ <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
49
+ </a>
50
+
51
+ - **[EDM (Elucidating the Design Space of Diffusion-based Generative Models)](tutorial%20notebooks/edm%20tutorial.ipynb)**
52
+ - **TODO** A thorough guide to EDM, discussing the innovative approaches and techniques used in this advanced diffusion model.
53
+
54
+ <a target="_blank" href="https://colab.research.google.com/github/AshishKumar4/FlaxDiff/blob/main/tutorial%20notebooks/edm%20tutorial.ipynb">
55
+ <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
56
+ </a>
57
+
58
+ These notebooks aim to provide a very easy to understand and step-by-step guide to the various diffusion models and techniques. They are designed to be beginner-friendly, and thus although they may not adhere to the exact formulations and implementations of the original papers to make them more understandable and generalizable, I have tried my best to keep them as accurate as possible. If you find any mistakes or have any suggestions, please feel free to open an issue or a pull request.
59
+
60
+ #### Other resources
61
+
62
+ - **[Multi-host Data parallel training script in JAX](./training.py)**
63
+ - Training script for multi-host data parallel training in JAX, to serve as a reference for training large models on multiple GPUs/TPUs across multiple hosts. A full-fledged tutorial notebook is in the works.
64
+
65
+ - **[TPU utilities for making life easier](./tpu-tools/)**
66
+ - A collection of utilities and scripts to make working with TPUs easier, such as cli to create/start/stop/setup TPUs, script to setup TPU VMs (install everything you need), mounting gcs datasets etc.
67
+
68
+ ## Disclaimer (and About Me)
69
+
70
+ I worked as a Machine Learning Researcher at Hyperverge from 2019-2021, focusing on computer vision, specifically facial anti-spoofing and facial detection & recognition. Since switching to my current job in 2021, I haven't engaged in as much R&D work, leading me to start this pet project to revisit and relearn the fundamentals and get familiar with the state-of-the-art. My current role involves primarily Golang system engineering with some applied ML work just sprinkled in. Therefore, the code may reflect my learning journey. Please forgive any mistakes and do open an issue to let me know.
71
+
72
+ Also, few of the text may be generated with help of github copilot, so please excuse any mistakes in the text.
73
+
74
+ ## Index
75
+
76
+ - [A Versatile and Easy-to-Understand Diffusion Library](#a-versatile-and-easy-to-understand-diffusion-library)
77
+ - [Disclaimer (and About Me)](#disclaimer-and-about-me)
78
+ - [Features](#features)
79
+ - [Schedulers](#schedulers)
80
+ - [Model Predictors](#model-predictors)
81
+ - [Samplers](#samplers)
82
+ - [Training](#training)
83
+ - [Models](#models)
84
+ - [Installation of FlaxDiff](#installation)
85
+ - [Getting Started with FlaxDiff](#getting-started)
86
+ - [Training Example](#training-example)
87
+ - [Inference Example](#inference-example)
88
+ - [References and Acknowledgements](#references-and-acknowledgements)
89
+ - [Pending things to do list](#pending-things-to-do-list)
90
+ - [Gallery](#gallery)
91
+ - [Contribution](#contribution)
92
+ - [License](#license)
93
+
94
+ ## Features
95
+
96
+ ### Schedulers
97
+ Implemented in `flaxdiff.schedulers`:
98
+ - **LinearNoiseSchedule** (`flaxdiff.schedulers.LinearNoiseSchedule`): A beta-parameterized discrete scheduler.
99
+ - **CosineNoiseSchedule** (`flaxdiff.schedulers.CosineNoiseSchedule`): A beta-parameterized discrete scheduler.
100
+ - **ExpNoiseSchedule** (`flaxdiff.schedulers.ExpNoiseSchedule`): A beta-parameterized discrete scheduler.
101
+ - **CosineContinuousNoiseScheduler** (`flaxdiff.schedulers.CosineContinuousNoiseScheduler`): A continuous scheduler.
102
+ - **CosineGeneralNoiseScheduler** (`flaxdiff.schedulers.CosineGeneralNoiseScheduler`): A continuous sigma parameterized cosine scheduler.
103
+ - **KarrasVENoiseScheduler** (`flaxdiff.schedulers.KarrasVENoiseScheduler`): A sigma-parameterized continuous scheduler proposed by Karras et al. 2022, best suited for inference.
104
+ - **EDMNoiseScheduler** (`flaxdiff.schedulers.EDMNoiseScheduler`): A sigma-parameterized continuous scheduler based on the Exponential Diffusion Model (EDM), best suited for training with the KarrasKarrasVENoiseScheduler.
105
+
106
+ ### Model Predictors
107
+ Implemented in `flaxdiff.predictors`:
108
+ - **EpsilonPredictor** (`flaxdiff.predictors.EpsilonPredictor`): Predicts the noise in the data.
109
+ - **X0Predictor** (`flaxdiff.predictors.X0Predictor`): Predicts the original data from the noisy data.
110
+ - **VPredictor** (`flaxdiff.predictors.VPredictor`): Predicts a linear combination of the data and noise, commonly used in the EDM.
111
+ - **KarrasEDMPredictor** (`flaxdiff.predictors.KarrasEDMPredictor`): A generalized predictor for the EDM, integrating various parameterizations.
112
+
113
+ ### Samplers
114
+ Implemented in `flaxdiff.samplers`:
115
+ - **DDPMSampler** (`flaxdiff.samplers.DDPMSampler`): Implements the Denoising Diffusion Probabilistic Model (DDPM) sampling process.
116
+ - **DDIMSampler** (`flaxdiff.samplers.DDIMSampler`): Implements the Denoising Diffusion Implicit Model (DDIM) sampling process.
117
+ - **EulerSampler** (`flaxdiff.samplers.EulerSampler`): An ODE solver sampler using Euler's method.
118
+ - **HeunSampler** (`flaxdiff.samplers.HeunSampler`): An ODE solver sampler using Heun's method.
119
+ - **RK4Sampler** (`flaxdiff.samplers.RK4Sampler`): An ODE solver sampler using the Runge-Kutta method.
120
+ - **MultiStepDPM** (`flaxdiff.samplers.MultiStepDPM`): Implements a multi-step sampling method inspired by the Multistep DPM solver as presented here: [tonyduan/diffusion](https://github.com/tonyduan/diffusion/blob/fcc0ed829baf29e1493b460b073e735a848c08ea/src/samplers.py#L44))
121
+
122
+ ### Training
123
+ Implemented in `flaxdiff.trainer`:
124
+ - **DiffusionTrainer** (`flaxdiff.trainer.DiffusionTrainer`): A class designed to facilitate the training of diffusion models. It manages the training loop, loss calculation, and model updates.
125
+
126
+ ### Models
127
+ Implemented in `flaxdiff.models`:
128
+ - **UNet** (`flaxdiff.models.simple_unet.SimpleUNet`): A sample UNET architecture for diffusion models.
129
+ - **Layers**: A library of layers including upsampling (`flaxdiff.models.simple_unet.Upsample`), downsampling (`flaxdiff.models.simple_unet.Downsample`), Time embeddings (`flaxdiff.models.simple_unet.FouriedEmbedding`), attention (`flaxdiff.models.simple_unet.AttentionBlock`), and residual blocks (`flaxdiff.models.simple_unet.ResidualBlock`).
130
+
131
+ ## Installation
132
+
133
+ To install FlaxDiff, you need to have Python 3.10 or higher. Install the required dependencies using:
134
+
135
+ ```bash
136
+ pip install -r requirements.txt
137
+ ```
138
+
139
+ The models were trained and tested with jax==0.4.28 and flax==0.8.4. However, when I updated to the latest jax==0.4.30 and flax==0.8.5,
140
+ the models stopped training. There seems to have been some major change breaking the training dynamics and therefore I would recommend
141
+ sticking to the versions mentioned in the requirements.txt
142
+
143
+ ## Getting Started
144
+
145
+ ### Training Example
146
+
147
+ Here is a simplified example to get you started with training a diffusion model using FlaxDiff:
148
+
149
+ ```python
150
+ from flaxdiff.schedulers import EDMNoiseScheduler
151
+ from flaxdiff.predictors import KarrasPredictionTransform
152
+ from flaxdiff.models.simple_unet import SimpleUNet as UNet
153
+ from flaxdiff.trainer import DiffusionTrainer
154
+ import jax
155
+ import optax
156
+ from datetime import datetime
157
+
158
+ BATCH_SIZE = 16
159
+ IMAGE_SIZE = 64
160
+
161
+ # Define noise scheduler
162
+ edm_schedule = EDMNoiseScheduler(1, sigma_max=80, rho=7, sigma_data=0.5)
163
+
164
+ # Define model
165
+ unet = UNet(emb_features=256,
166
+ feature_depths=[64, 128, 256, 512],
167
+ attention_configs=[{"heads":4}, {"heads":4}, {"heads":4}, {"heads":4}, {"heads":4}],
168
+ num_res_blocks=2,
169
+ num_middle_res_blocks=1)
170
+
171
+ # Load dataset
172
+ data, datalen = get_dataset("oxford_flowers102", batch_size=BATCH_SIZE, image_scale=IMAGE_SIZE)
173
+ batches = datalen // BATCH_SIZE
174
+
175
+ # Define optimizer
176
+ solver = optax.adam(2e-4)
177
+
178
+ # Create trainer
179
+ trainer = DiffusionTrainer(unet, optimizer=solver,
180
+ noise_schedule=edm_schedule,
181
+ rngs=jax.random.PRNGKey(4),
182
+ name="Diffusion_SDE_VE_" + datetime.now().strftime("%Y-%m-%d_%H:%M:%S"),
183
+ model_output_transform=KarrasPredictionTransform(sigma_data=edm_schedule.sigma_data))
184
+
185
+ # Train the model
186
+ final_state = trainer.fit(data, batches, epochs=2000)
187
+ ```
188
+
189
+ ### Inference Example
190
+
191
+ Here is a simplified example for generating images using a trained model:
192
+
193
+ ```python
194
+ from flaxdiff.samplers import DiffusionSampler
195
+
196
+ class EulerSampler(DiffusionSampler):
197
+ def take_next_step(self, current_samples, reconstructed_samples, pred_noise, current_step, state, next_step=None):
198
+ current_alpha, current_sigma = self.noise_schedule.get_rates(current_step)
199
+ next_alpha, next_sigma = self.noise_schedule.get_rates(next_step)
200
+ dt = next_sigma - current_sigma
201
+ x_0_coeff = (current_alpha * next_sigma - next_alpha * current_sigma) / dt
202
+ dx = (current_samples - x_0_coeff * reconstructed_samples) / current_sigma
203
+ next_samples = current_samples + dx * dt
204
+ return next_samples, state
205
+
206
+ # Create sampler
207
+ sampler = EulerSampler(trainer.model, trainer.state.ema_params, edm_schedule, model_output_transform=trainer.model_output_transform)
208
+
209
+ # Generate images
210
+ samples = sampler.generate_images(num_images=64, diffusion_steps=100, start_step=1000, end_step=0)
211
+ plotImages(samples, dpi=300)
212
+ ```
213
+
214
+ ## References and Acknowledgements
215
+
216
+ ### Research papers and preprints
217
+ - The Original Denoising Diffusion Probabilistic Models (DDPM) [paper](https://arxiv.org/abs/2006.11239)
218
+ - Denoising Diffusion Implicit Models (DDIM) [paper](https://arxiv.org/abs/2010.02502)
219
+ - Improved Denoising Diffusion Probabilistic Models [paper](https://arxiv.org/abs/2102.09672)
220
+ - Diffusion Models beat GANs on image synthesis [paper](https://arxiv.org/pdf/2105.05233)
221
+ - Score-Based Generative Modeling through Stochastic Differential Equations [paper](https://arxiv.org/pdf/2011.13456)
222
+ - Elucidating the design space of Diffusion-based generative models (EDM) [paper](https://arxiv.org/abs/2206.00364)
223
+ - Perception Prioritized Training of Diffusion Models (P2 Weighting) [paper](https://arxiv.org/abs/2204.00227)
224
+ - Pseudo Numerical Methods for Diffusion Models on Manifolds (PNMDM) [paper](https://arxiv.org/abs/2202.09778)
225
+ - The DPM-Solver:A Fast ODE Solver for Diffusion Probabilistic Model Sampling in Around 10 Steps [paper](https://arxiv.org/pdf/2206.00927)
226
+
227
+ ### Useful blogs and codebases
228
+
229
+ - An incredible series of blogs on various diffusion related topics by [Sander Dieleman](https://sander.ai/posts/). The posts particularly on [diffusion models](https://sander.ai/2022/01/31/diffusion.html), [Typicality](https://sander.ai/2020/09/01/typicality.html), [Geometry of Diffusion Guidance](https://sander.ai/2023/08/28/geometry.html#warning) and [Noise Schedules](https://sander.ai/2024/06/14/noise-schedules.html) are a must read
230
+ - An awesome blog series by Tony Duan on [Diffusion models from scratch](https://www.tonyduan.com/diffusion/index.html). Although it trains models for MNIST and the implementations are a bit basic, the maths is explained in a very nice way. The codebase is [here](https://github.com/tonyduan/diffusion)
231
+ - The [k-diffusion](https://github.com/crowsonkb/k-diffusion/) codebase Katherine Crowson, which hosts an exhaustive implementation of the EDM paper (Karras et al) along with the DPM-Solver, DPM-Solver++ (both 2S and 2M) in pytorch. Most other diffusion libraries borrow from this.
232
+ - The [Official EDM implementation](https://github.com/NVlabs/edm) by Tero Karras, in pytorch. Really neat code and the reference implementation for all the karras based samplers/schedules.
233
+ - The [Hugging Face Diffusers Library](https://github.com/huggingface/diffusers), Arguably the most complete set of implementations for the latest state-of-the-art techniques and concepts in this field. Written mainly in pytorch, but with flax implementations also available for a lot of the concepts, the focus of this repository is on completeness and ease of understanding as well.
234
+ - The [Keras DDPM Tutorial](https://keras.io/examples/generative/ddpm/) by A_K Nain, and the [Keras DDIM implementation](https://keras.io/examples/generative/ddim/) by András Béres, which are great starting points for beginners to understand the basics of diffusion models. I started my journey by trying to implement the concepts introduced in these tutorials from scratch.
235
+ - Special thanks to ChatGPT-4 by OpenAI for helping clear my doubts.
236
+
237
+ ## Pending things to do list
238
+
239
+ - **Advanced solvers like DPM/DPM2/DPM++ etc**
240
+ - **SDE versions of the current ODE solvers i.e, ancestral sampling**
241
+ - **Text Conditioned image generation**
242
+ - **Classifier and Classified Free Guidance**
243
+
244
+ ## Gallery
245
+
246
+ ### Images generated by Euler Ancestral Sampler in 200 Steps [text2image with CFG]
247
+ Model trained on Laion-Aesthetics 12M + CC12M + MS COCO + 1M aesthetic 6+ subset of COYO-700M on TPU-v4-32:
248
+ `a beautiful landscape with a river with mountains, a beautiful landscape with a river with mountains, a beautiful landscape with a river with mountains, a beautiful landscape with a river with mountains, a beautiful landscape with a river with mountains, a beautiful landscape with a river with mountains, a beautiful landscape with a river with mountains, a beautiful landscape with a river with mountains, a beautiful landscape with a river with mountains, a beautiful landscape with a river with mountains, a beautiful landscape with a river with mountains, a beautiful landscape with a river with mountains, a beautiful landscape with a river with mountains, a beautiful landscape with a river with mountains, a beautiful landscape with a river with mountains, a beautiful landscape with a river with mountains, a beautiful forest with a river and sunlight, a beautiful forest with a river and sunlight, a beautiful forest with a river and sunlight, a beautiful forest with a river and sunlight, a beautiful forest with a river and sunlight, a beautiful forest with a river and sunlight, a beautiful forest with a river and sunlight, a beautiful forest with a river and sunlight, a big mansion with a garden, a big mansion with a garden, a big mansion with a garden, a big mansion with a garden, a big mansion with a garden, a big mansion with a garden, a big mansion with a garden, a big mansion with a garden`
249
+
250
+ **Params**:
251
+ `Dataset: Laion-Aesthetics 12M + CC12M + MS COCO + 1M aesthetic 6+ subset of COYO-700M`
252
+ `Batch size: 256`
253
+ `Image Size: 128`
254
+ `Training Epochs: 5`
255
+ `Steps per epoch: 74573`
256
+ `Model Configurations: feature_depths=[128, 256, 512, 1024]`
257
+
258
+ `Training Noise Schedule: EDMNoiseScheduler`
259
+ `Inference Noise Schedule: KarrasEDMPredictor`
260
+
261
+ ![EulerA with CFG](images/medium_epoch5.png)
262
+
263
+ ### Images generated by Euler Ancestral Sampler in 200 Steps [text2image with CFG]
264
+ Images generated by the following prompts using classifier free guidance with guidance factor = 2:
265
+ `'water tulip, a water lily, a water lily, a water lily, a photo of a marigold, a water lily, a water lily, a photo of a lotus, a photo of a lotus, a photo of a lotus, a photo of a rose, a photo of a rose, a photo of a rose, a photo of a rose, a photo of a rose'`
266
+
267
+ **Params**:
268
+ `Dataset: oxford_flowers102`
269
+ `Batch size: 16`
270
+ `Image Size: 128`
271
+ `Training Epochs: 1000`
272
+ `Steps per epoch: 511`
273
+
274
+ `Training Noise Schedule: EDMNoiseScheduler`
275
+ `Inference Noise Schedule: KarrasEDMPredictor`
276
+
277
+ ![EulerA with CFG](images/text2img%20euler%20ancestral%201.png)
278
+
279
+ ### Images generated by Euler Ancestral Sampler in 200 Steps [text2image with CFG]
280
+ Images generated by the following prompts using classifier free guidance with guidance factor = 4:
281
+ `'water tulip, a water lily, a water lily, a photo of a rose, a photo of a rose, a water lily, a water lily, a photo of a marigold, a photo of a marigold, a photo of a marigold, a water lily, a photo of a sunflower, a photo of a lotus, columbine, columbine, an orchid, an orchid, an orchid, a water lily, a water lily, a water lily, columbine, columbine, a photo of a sunflower, a photo of a sunflower, a photo of a sunflower, a photo of a lotus, a photo of a lotus, a photo of a marigold, a photo of a marigold, a photo of a rose, a photo of a rose, a photo of a rose, orange dahlia, orange dahlia, a lenten rose, a lenten rose, a water lily, a water lily, a water lily, a water lily, an orchid, an orchid, an orchid, hard-leaved pocket orchid, bird of paradise, bird of paradise, a photo of a lovely rose, a photo of a lovely rose, a photo of a globe-flower, a photo of a globe-flower, a photo of a lovely rose, a photo of a lovely rose, a photo of a ruby-lipped cattleya, a photo of a ruby-lipped cattleya, a photo of a lovely rose, a water lily, a osteospermum, a osteospermum, a water lily, a water lily, a water lily, a red rose, a red rose'`
282
+
283
+ **Params**:
284
+ `Dataset: oxford_flowers102`
285
+ `Batch size: 16`
286
+ `Image Size: 128`
287
+ `Training Epochs: 1000`
288
+ `Steps per epoch: 511`
289
+
290
+ `Training Noise Schedule: EDMNoiseScheduler`
291
+ `Inference Noise Schedule: KarrasEDMPredictor`
292
+
293
+ ![EulerA with CFG](images/text2img%20euler%20ancestral%202.png)
294
+
295
+ ### Images generated by DDPM Sampler in 1000 steps [Unconditional]
296
+
297
+ **Params**:
298
+ `Dataset: oxford_flowers102`
299
+ `Batch size: 16`
300
+ `Image Size: 64`
301
+ `Training Epochs: 1000`
302
+ `Steps per epoch: 511`
303
+
304
+ `Training Noise Schedule: CosineNoiseSchedule`
305
+ `Inference Noise Schedule: CosineNoiseSchedule`
306
+
307
+ `Model: UNet(emb_features=256,
308
+ feature_depths=[64, 128, 256, 512],
309
+ attention_configs=[{"heads":4}, {"heads":4}, {"heads":4}, {"heads":4}, {"heads":4}],
310
+ num_res_blocks=2,
311
+ num_middle_res_blocks=1)`
312
+
313
+ ![DDPM Sampler results](images/ddpm2.png)
314
+
315
+ ### Images generated by DDPM Sampler in 1000 steps [Unconditional]
316
+
317
+ **Params**:
318
+ `Dataset: oxford_flowers102`
319
+ `Batch size: 16`
320
+ `Image Size: 64`
321
+ `Training Epochs: 1000`
322
+ `Steps per epoch: 511`
323
+
324
+ `Training Noise Schedule: CosineNoiseSchedule`
325
+ `Inference Noise Schedule: CosineNoiseSchedule`
326
+
327
+ `Model: UNet(emb_features=256,
328
+ feature_depths=[64, 128, 256, 512],
329
+ attention_configs=[{"heads":4}, {"heads":4}, {"heads":4}, {"heads":4}, {"heads":4}],
330
+ num_res_blocks=2,
331
+ num_middle_res_blocks=1)`
332
+
333
+ ![DDPM Sampler results](images/ddpm.png)
334
+
335
+ ### Images generated by Heun Sampler in 10 steps (20 model inferences as Heun takes 2x inference steps) [Unconditional]
336
+
337
+ **Params**:
338
+ `Dataset: oxford_flowers102`
339
+ `Batch size: 16`
340
+ `Image Size: 64`
341
+ `Training Epochs: 1000`
342
+ `Steps per epoch: 511`
343
+
344
+ `Training Noise Schedule: EDMNoiseScheduler`
345
+ `Inference Noise Schedule: KarrasEDMPredictor`
346
+
347
+ `Model: UNet(emb_features=256,
348
+ feature_depths=[64, 128, 256, 512],
349
+ attention_configs=[{"heads":4}, {"heads":4}, {"heads":4}, {"heads":4}, {"heads":4}],
350
+ num_res_blocks=2,
351
+ num_middle_res_blocks=1)`
352
+
353
+ ![Heun Sampler results](images/heun.png)
354
+
355
+
356
+ ## Contribution
357
+
358
+ Feel free to contribute by opening issues or submitting pull requests. Let's make FlaxDiff better together!
359
+
360
+ ## License
361
+
362
+ This project is licensed under the MIT License.