Upload README.md
Browse files
README.md
ADDED
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: creativeml-openrail-m
|
3 |
+
tags:
|
4 |
+
- stable-diffusion
|
5 |
+
- stable-diffusion-diffusers
|
6 |
+
- text-to-image
|
7 |
+
datasets:
|
8 |
+
- ChristophSchuhmann/improved_aesthetics_6.25plus
|
9 |
+
library_name: diffusers
|
10 |
+
pipeline_tag: text-to-image
|
11 |
+
extra_gated_prompt: >-
|
12 |
+
This model is open access and available to all, with a CreativeML OpenRAIL-M
|
13 |
+
license further specifying rights and usage.
|
14 |
+
|
15 |
+
The CreativeML OpenRAIL License specifies:
|
16 |
+
|
17 |
+
|
18 |
+
1. You can't use the model to deliberately produce nor share illegal or
|
19 |
+
harmful outputs or content
|
20 |
+
|
21 |
+
2. The authors claim no rights on the outputs you generate, you are free to
|
22 |
+
use them and are accountable for their use which must not go against the
|
23 |
+
provisions set in the license
|
24 |
+
|
25 |
+
3. You may re-distribute the weights and use the model commercially and/or as
|
26 |
+
a service. If you do, please be aware you have to include the same use
|
27 |
+
restrictions as the ones in the license and share a copy of the CreativeML
|
28 |
+
OpenRAIL-M to all your users (please read the license entirely and carefully)
|
29 |
+
|
30 |
+
Please read the full license carefully here:
|
31 |
+
https://huggingface.co/spaces/CompVis/stable-diffusion-license
|
32 |
+
|
33 |
+
extra_gated_heading: Please read the LICENSE to access this model
|
34 |
+
|
35 |
+
---
|
36 |
+
|
37 |
+
|
38 |
+
# BK-SDM-2M Model Card
|
39 |
+
|
40 |
+
BK-SDM-{[**Base-2M**](https://huggingface.co/nota-ai/bk-sdm-base-2m), [**Small-2M**](https://huggingface.co/nota-ai/bk-sdm-small-2m), [**Tiny-2M**](https://huggingface.co/nota-ai/bk-sdm-tiny-2m)} are pretrained with **10× more data** (2.3M LAION image-text pairs) compared to our previous release.
|
41 |
+
- Block-removed Knowledge-distilled Stable Diffusion Model (BK-SDM) is an architecturally compressed SDM for efficient text-to-image synthesis.
|
42 |
+
- The previous BK-SDM-{[Base](https://huggingface.co/nota-ai/bk-sdm-base), [Small](https://huggingface.co/nota-ai/bk-sdm-small), [Tiny](https://huggingface.co/nota-ai/bk-sdm-tiny)} were obtained via distillation pretraining on 0.22M LAION pairs.
|
43 |
+
- Resources for more information: [Paper](https://arxiv.org/abs/2305.15798), [GitHub](https://github.com/Nota-NetsPresso/BK-SDM), [Demo]( https://huggingface.co/spaces/nota-ai/compressed-stable-diffusion).
|
44 |
+
|
45 |
+
|
46 |
+
## Examples with 🤗[Diffusers library](https://github.com/huggingface/diffusers).
|
47 |
+
|
48 |
+
An inference code with the default PNDM scheduler and 50 denoising steps is as follows.
|
49 |
+
|
50 |
+
```python
|
51 |
+
import torch
|
52 |
+
from diffusers import StableDiffusionPipeline
|
53 |
+
|
54 |
+
pipe = StableDiffusionPipeline.from_pretrained("nota-ai/bk-sdm-tiny-2m", torch_dtype=torch.float16)
|
55 |
+
pipe = pipe.to("cuda")
|
56 |
+
|
57 |
+
prompt = "a black vase holding a bouquet of roses"
|
58 |
+
image = pipe(prompt).images[0]
|
59 |
+
|
60 |
+
image.save("example.png")
|
61 |
+
```
|
62 |
+
|
63 |
+
|
64 |
+
## Compression Method
|
65 |
+
|
66 |
+
Adhering to the [U-Net architecture](https://huggingface.co/nota-ai/bk-sdm-tiny#u-net-architecture) and [distillation pretraining](https://huggingface.co/nota-ai/bk-sdm-tiny#distillation-pretraining) of BK-SDM, the difference in BK-SDM-2M is a 10× increase in the number of training pairs.
|
67 |
+
|
68 |
+
- **Training Data**: 2,256,472 image-text pairs (i.e., 2.3M pairs) from [LAION-Aesthetics V2 6.25+](https://laion.ai/blog/laion-aesthetics/).
|
69 |
+
- **Hardware:** A single NVIDIA A100 80GB GPU
|
70 |
+
- **Gradient Accumulations**: 4
|
71 |
+
- **Batch:** 256 (=4×64)
|
72 |
+
- **Optimizer:** AdamW
|
73 |
+
- **Learning Rate:** a constant learning rate of 5e-5 for 50K-iteration pretraining
|
74 |
+
|
75 |
+
|
76 |
+
## Experimental Results
|
77 |
+
|
78 |
+
The following table shows the zero-shot results on 30K samples from the MS-COCO validation split. After generating 512×512 images with the PNDM scheduler and 25 denoising steps, we downsampled them to 256×256 for evaluating generation scores.
|
79 |
+
|
80 |
+
- Our models were drawn at the 50K-th training iteration.
|
81 |
+
|
82 |
+
| Model | FID↓ | IS↑ | CLIP Score↑<br>(ViT-g/14) | # Params,<br>U-Net | # Params,<br>Whole SDM |
|
83 |
+
|:---:|:---:|:---:|:---:|:---:|:---:|
|
84 |
+
| [Stable Diffusion v1.4](https://huggingface.co/CompVis/stable-diffusion-v1-4) | 13.05 | 36.76 | 0.2958 | 0.86B | 1.04B |
|
85 |
+
| [BK-SDM-Base](https://huggingface.co/nota-ai/bk-sdm-base) (Ours) | 15.76 | 33.79 | 0.2878 | 0.58B | 0.76B |
|
86 |
+
| [BK-SDM-Base-2M](https://huggingface.co/nota-ai/bk-sdm-base-2m) (Ours) | 14.81 | 34.17 | 0.2883 | 0.58B | 0.76B |
|
87 |
+
| [BK-SDM-Small](https://huggingface.co/nota-ai/bk-sdm-small) (Ours) | 16.98 | 31.68 | 0.2677 | 0.49B | 0.66B |
|
88 |
+
| [BK-SDM-Small-2M](https://huggingface.co/nota-ai/bk-sdm-small-2m) (Ours) | 17.05 | 33.10 | 0.2734 | 0.49B | 0.66B |
|
89 |
+
| [BK-SDM-Tiny](https://huggingface.co/nota-ai/bk-sdm-tiny) (Ours) | 17.12 | 30.09 | 0.2653 | 0.33B | 0.50B |
|
90 |
+
| [BK-SDM-Tiny-2M](https://huggingface.co/nota-ai/bk-sdm-tiny-2m) (Ours) | 17.53 | 31.32 | 0.2690 | 0.33B | 0.50B |
|
91 |
+
|
92 |
+
|
93 |
+
|
94 |
+
### Effect of Different Data Sizes for Training BK-SDM-Small
|
95 |
+
Increasing the number of training pairs improves the IS and CLIP scores over training progress. The MS-COCO 256×256 30K benchmark was used for evaluation.
|
96 |
+
|
97 |
+
<center>
|
98 |
+
<img alt="Training progress with different data sizes" img src="https://netspresso-research-code-release.s3.us-east-2.amazonaws.com/assets-bk-sdm/fig_iter_data_size.png" width="100%">
|
99 |
+
</center>
|
100 |
+
|
101 |
+
Furthermore, with the growth in data volume, visual results become more favorable (e.g., better image-text alignment and clear distinction among objects).
|
102 |
+
|
103 |
+
<center>
|
104 |
+
<img alt="Visual results with different data sizes" img src="https://netspresso-research-code-release.s3.us-east-2.amazonaws.com/assets-bk-sdm/fig_results_data_size.png" width="100%">
|
105 |
+
</center>
|
106 |
+
|
107 |
+
### Additional Visual Examples
|
108 |
+
|
109 |
+
<center>
|
110 |
+
<img alt="additional visual examples" img src="https://netspresso-research-code-release.s3.us-east-2.amazonaws.com/assets-bk-sdm/fig_results_models_2m.png" width="100%">
|
111 |
+
</center>
|
112 |
+
|
113 |
+
|
114 |
+
# Uses
|
115 |
+
Follow [the usage guidelines of Stable Diffusion v1](https://huggingface.co/CompVis/stable-diffusion-v1-4#uses).
|
116 |
+
|
117 |
+
|
118 |
+
# Acknowledgments
|
119 |
+
- We express our gratitude to [Microsoft for Startups Founders Hub](https://www.microsoft.com/en-us/startups) for generously providing the Azure credits used during pretraining.
|
120 |
+
- We deeply appreciate the pioneering research on Latent/Stable Diffusion conducted by [CompVis](https://github.com/CompVis/latent-diffusion), [Runway](https://runwayml.com/), and [Stability AI](https://stability.ai/).
|
121 |
+
- Special thanks to the contributors to [LAION](https://laion.ai/), [Diffusers](https://github.com/huggingface/diffusers), and [Gradio](https://www.gradio.app/) for their valuable support.
|
122 |
+
|
123 |
+
|
124 |
+
# Citation
|
125 |
+
```bibtex
|
126 |
+
@article{kim2023architectural,
|
127 |
+
title={On Architectural Compression of Text-to-Image Diffusion Models},
|
128 |
+
author={Kim, Bo-Kyeong and Song, Hyoung-Kyu and Castells, Thibault and Choi, Shinkook},
|
129 |
+
journal={arXiv preprint arXiv:2305.15798},
|
130 |
+
year={2023},
|
131 |
+
url={https://arxiv.org/abs/2305.15798}
|
132 |
+
}
|
133 |
+
```
|
134 |
+
```bibtex
|
135 |
+
@article{Kim_2023_ICMLW,
|
136 |
+
title={BK-SDM: Architecturally Compressed Stable Diffusion for Efficient Text-to-Image Generation},
|
137 |
+
author={Kim, Bo-Kyeong and Song, Hyoung-Kyu and Castells, Thibault and Choi, Shinkook},
|
138 |
+
journal={ICML Workshop on Efficient Systems for Foundation Models (ES-FoMo)},
|
139 |
+
year={2023},
|
140 |
+
url={https://openreview.net/forum?id=bOVydU0XKC}
|
141 |
+
}
|
142 |
+
```
|
143 |
+
|
144 |
+
*This model card was written by Bo-Kyeong Kim and is based on the [Stable Diffusion v1 model card]( https://huggingface.co/CompVis/stable-diffusion-v1-4).*
|