Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,81 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- poloclub/diffusiondb
|
5 |
+
base_model:
|
6 |
+
- stabilityai/stable-diffusion-2-1-base
|
7 |
+
pipeline_tag: text-to-image
|
8 |
+
library_name: diffusers
|
9 |
+
---
|
10 |
+
# AMD Nitro Diffusion
|
11 |
+
|
12 |
+
|
13 |
+
![image/jpeg](https://cdn-uploads.huggingface.co/production/uploads/6355aded9c72a7e742f341a4/AsUvS7acUDLZhKOMRSH37.jpeg)
|
14 |
+
|
15 |
+
## Introduction
|
16 |
+
AMD Nitro Diffusion is a series of efficient text-to-image generation models that are distilled from popular diffusion models on AMD Instinct™ GPUs. The release consists of:
|
17 |
+
|
18 |
+
* Stable Diffusion 2.1 Nitro: a UNet-based one-step model distilled from [Stable Diffusion 2.1](https://huggingface.co/stabilityai/stable-diffusion-2-1-base).
|
19 |
+
* PixArt-Sigma Nitro: a transformer-based high resolution one-step model distilled from [PixArt-Sigma](https://pixart-alpha.github.io/PixArt-sigma-project/).
|
20 |
+
|
21 |
+
⚡️ [Open-source code](https://github.com/AMD-AIG-AIMA/AMD-Diffusion-Distillation)! The models are based on our re-implementation of [Latent Adversarial Diffusion Distillation](https://arxiv.org/abs/2403.12015), the method used to build the popular Stable Diffusion 3 Turbo model. Since the original authors didn't provide training code, we release our re-implementation to help advance further research in the field.
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
## Details
|
26 |
+
|
27 |
+
* **Model architecture**: Stable Diffusion 2.1 Nitro has the same architecture as Stable Diffusion 2.1 and is compatible with the diffusers pipeline.
|
28 |
+
* **Inference steps**: This model is distilled to perform inference in just a single step. However, the training code also supports distilling a model for 2, 4 or 8 steps.
|
29 |
+
* **Hardware**: We use a single node consisting of 4 AMD Instinct™ MI250 GPUs for distilling Stable Diffusion 2.1 Nitro.
|
30 |
+
* **Dataset**: We use 1M prompts from [DiffusionDB](https://huggingface.co/datasets/poloclub/diffusiondb) and generate the corresponding images from the base Stable Diffusion 2.1 Nitro model.
|
31 |
+
* **Training cost**: The distillation process achieves reasonable results in less than 2 days on a single node.
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
## Quickstart
|
36 |
+
|
37 |
+
```python
|
38 |
+
from diffusers import DDPMScheduler, DiffusionPipeline
|
39 |
+
import torch
|
40 |
+
|
41 |
+
scheduler = DDPMScheduler.from_pretrained("stabilityai/stable-diffusion-2-1-base", subfolder="scheduler")
|
42 |
+
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1-base", scheduler=scheduler)
|
43 |
+
|
44 |
+
ckpt_path = '<path to distilled checkpoint>'
|
45 |
+
unet_state_dict = torch.load(ckpt_path)
|
46 |
+
pipe.unet.load_state_dict(unet_state_dict)
|
47 |
+
pipe = pipe.to("cuda")
|
48 |
+
|
49 |
+
image = pipe(prompt='a photo of a cat',
|
50 |
+
num_inference_steps=1,
|
51 |
+
guidance_scale=0,
|
52 |
+
timesteps=[999]).images[0]
|
53 |
+
```
|
54 |
+
|
55 |
+
For more details on training and evaluation please visit the [GitHub repo](https://github.com/AMD-AIG-AIMA/AMD-Diffusion-Distillation).
|
56 |
+
|
57 |
+
|
58 |
+
|
59 |
+
## Results
|
60 |
+
|
61 |
+
|
62 |
+
Compared to the [Stable Diffusion 2.1 base model](https://huggingface.co/stabilityai/stable-diffusion-2-1-base), we achieve 95.9% reduction in FLOPs at the cost of just 2.5% lower CLIP score and 2.2% higher FID.
|
63 |
+
|
64 |
+
| Model | FID ↓ | CLIP ↑ |FLOPs| Latency on AMD Instinct MI250 (sec)
|
65 |
+
| :---: | :---: | :---: | :---: | :---:
|
66 |
+
| Stable Diffusion 2.1 base, 50 steps (cfg=7.5) | 25.47 | 0.3286 |83.04 | 4.94
|
67 |
+
| **Stable Diffusion 2.1 Nitro**, 1 step | 26.04 | 0.3204|3.36 | 0.18
|
68 |
+
|
69 |
+
|
70 |
+
|
71 |
+
## License
|
72 |
+
Copyright (c) 2018-2024 Advanced Micro Devices, Inc. All Rights Reserved.
|
73 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
74 |
+
you may not use this file except in compliance with the License.
|
75 |
+
You may obtain a copy of the License at
|
76 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
77 |
+
Unless required by applicable law or agreed to in writing, software
|
78 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
79 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
80 |
+
See the License for the specific language governing permissions and
|
81 |
+
limitations under the License.
|