pcuenq HF staff commited on
Commit
2f36b5d
1 Parent(s): 51bdc11

Model card.

Browse files
Files changed (1) hide show
  1. README.md +195 -0
README.md ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ tags:
4
+ - stable-diffusion
5
+ - stable-diffusion-diffusers
6
+ - text-to-image
7
+ - core-ml
8
+ ---
9
+
10
+ # Stable Diffusion v1-4 Model Card (Palettized Core ML Weights)
11
+
12
+ This model was generated by Hugging Face using [Apple’s repository](https://github.com/apple/ml-stable-diffusion) which has [ASCL](https://github.com/apple/ml-stable-diffusion/blob/main/LICENSE.md). This version contains 6-bit palettized Core ML weights for iOS 17 or macOS 14. To use weights without quantization, please visit [this model instead](https://huggingface.co/apple/coreml-stable-diffusion-v1-4).
13
+
14
+ ## Model Description
15
+
16
+ Stable Diffusion is a latent text-to-image diffusion model capable of generating photo-realistic images given any text input.
17
+ For more information about how Stable Diffusion functions, please have a look at [🤗's Stable Diffusion with 🧨Diffusers blog](https://huggingface.co/blog/stable_diffusion).
18
+
19
+ The **Stable-Diffusion-v1-4** checkpoint was initialized with the weights of the [Stable-Diffusion-v1-2](https:/steps/huggingface.co/CompVis/stable-diffusion-v1-2)
20
+ checkpoint and subsequently fine-tuned on 225k steps at resolution 512x512 on "laion-aesthetics v2 5+" and 10% dropping of the text-conditioning to improve [classifier-free guidance sampling](https://arxiv.org/abs/2207.12598).
21
+
22
+ These weights here have been converted to Core ML for use on Apple Silicon hardware.
23
+
24
+ There are 4 variants of the Core ML weights:
25
+
26
+ ```
27
+ coreml-stable-diffusion-v1-4
28
+ ├── original
29
+ │ ├── compiled # Swift inference, "original" attention
30
+ │ └── packages # Python inference, "original" attention
31
+ └── split_einsum
32
+ ├── compiled # Swift inference, "split_einsum" attention
33
+ └── packages # Python inference, "split_einsum" attention
34
+ ```
35
+
36
+ There are also two zip archives suitable for use in the [Hugging Face demo app](https://github.com/huggingface/swift-coreml-diffusers) and other third party tools:
37
+
38
+ - `coreml-stable-diffusion-1-4-palettized_original_compiled.zip` contains the compiled, 6-bit model with `ORIGINAL` attention implementation.
39
+ - `coreml-stable-diffusion-1-4-palettized_split_einsum_v2_compiled.zip` contains the compiled, 6-bit model with `SPLIT_EINSUM_V2` attention implementation.
40
+
41
+ Please, refer to https://huggingface.co/blog/diffusers-coreml for details.
42
+
43
+ If you need weights for the 🧨 Diffusers library, please [visit this model instead](https://huggingface.co/CompVis/stable-diffusion-v1-4).
44
+
45
+ ## Model Details
46
+ - **Developed by:** Robin Rombach, Patrick Esser
47
+ - **Model type:** Diffusion-based text-to-image generation model
48
+ - **Language(s):** English
49
+ - **License:** [The CreativeML OpenRAIL M license](https://huggingface.co/spaces/CompVis/stable-diffusion-license) is an [Open RAIL M license](https://www.licenses.ai/blog/2022/8/18/naming-convention-of-responsible-ai-licenses), adapted from the work that [BigScience](https://bigscience.huggingface.co/) and [the RAIL Initiative](https://www.licenses.ai/) are jointly carrying in the area of responsible AI licensing. See also [the article about the BLOOM Open RAIL license](https://bigscience.huggingface.co/blog/the-bigscience-rail-license) on which our license is based.
50
+ - **Model Description:** This is a model that can be used to generate and modify images based on text prompts. It is a [Latent Diffusion Model](https://arxiv.org/abs/2112.10752) that uses a fixed, pretrained text encoder ([CLIP ViT-L/14](https://arxiv.org/abs/2103.00020)) as suggested in the [Imagen paper](https://arxiv.org/abs/2205.11487).
51
+ - **Resources for more information:** [GitHub Repository](https://github.com/CompVis/stable-diffusion), [Paper](https://arxiv.org/abs/2112.10752).
52
+ - **Cite as:**
53
+
54
+ @InProceedings{Rombach_2022_CVPR,
55
+ author = {Rombach, Robin and Blattmann, Andreas and Lorenz, Dominik and Esser, Patrick and Ommer, Bj\"orn},
56
+ title = {High-Resolution Image Synthesis With Latent Diffusion Models},
57
+ booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
58
+ month = {June},
59
+ year = {2022},
60
+ pages = {10684-10695}
61
+ }
62
+
63
+ # Uses
64
+
65
+ ## Direct Use
66
+ The model is intended for research purposes only. Possible research areas and
67
+ tasks include
68
+
69
+ - Safe deployment of models which have the potential to generate harmful content.
70
+ - Probing and understanding the limitations and biases of generative models.
71
+ - Generation of artworks and use in design and other artistic processes.
72
+ - Applications in educational or creative tools.
73
+ - Research on generative models.
74
+
75
+ Excluded uses are described below.
76
+
77
+ ### Misuse, Malicious Use, and Out-of-Scope Use
78
+ _Note: This section is taken from the [DALLE-MINI model card](https://huggingface.co/dalle-mini/dalle-mini), but applies in the same way to Stable Diffusion_.
79
+
80
+ The model should not be used to intentionally create or disseminate images that create hostile or alienating environments for people. This includes generating images that people would foreseeably find disturbing, distressing, or offensive; or content that propagates historical or current stereotypes.
81
+
82
+ #### Out-of-Scope Use
83
+ The model was not trained to be factual or true representations of people or events, and therefore using the model to generate such content is out-of-scope for the abilities of this model.
84
+
85
+ #### Misuse and Malicious Use
86
+ Using the model to generate content that is cruel to individuals is a misuse of this model. This includes, but is not limited to:
87
+
88
+ - Generating demeaning, dehumanizing, or otherwise harmful representations of people or their environments, cultures, religions, etc.
89
+ - Intentionally promoting or propagating discriminatory content or harmful stereotypes.
90
+ - Impersonating individuals without their consent.
91
+ - Sexual content without consent of the people who might see it.
92
+ - Mis- and disinformation
93
+ - Representations of egregious violence and gore
94
+ - Sharing of copyrighted or licensed material in violation of its terms of use.
95
+ - Sharing content that is an alteration of copyrighted or licensed material in violation of its terms of use.
96
+
97
+ ## Limitations and Bias
98
+
99
+ ### Limitations
100
+
101
+ - The model does not achieve perfect photorealism
102
+ - The model cannot render legible text
103
+ - The model does not perform well on more difficult tasks which involve compositionality, such as rendering an image corresponding to “A red cube on top of a blue sphere”
104
+ - Faces and people in general may not be generated properly.
105
+ - The model was trained mainly with English captions and will not work as well in other languages.
106
+ - The autoencoding part of the model is lossy
107
+ - The model was trained on a large-scale dataset
108
+ [LAION-5B](https://laion.ai/blog/laion-5b/) which contains adult material
109
+ and is not fit for product use without additional safety mechanisms and
110
+ considerations.
111
+ - No additional measures were used to deduplicate the dataset. As a result, we observe some degree of memorization for images that are duplicated in the training data.
112
+ The training data can be searched at [https://rom1504.github.io/clip-retrieval/](https://rom1504.github.io/clip-retrieval/) to possibly assist in the detection of memorized images.
113
+
114
+ ### Bias
115
+
116
+ While the capabilities of image generation models are impressive, they can also reinforce or exacerbate social biases.
117
+ Stable Diffusion v1 was trained on subsets of [LAION-2B(en)](https://laion.ai/blog/laion-5b/),
118
+ which consists of images that are primarily limited to English descriptions.
119
+ Texts and images from communities and cultures that use other languages are likely to be insufficiently accounted for.
120
+ This affects the overall output of the model, as white and western cultures are often set as the default. Further, the
121
+ ability of the model to generate content with non-English prompts is significantly worse than with English-language prompts.
122
+
123
+ ### Safety Module
124
+
125
+ The intended use of this model is with the [Safety Checker](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/safety_checker.py) in Diffusers.
126
+ This checker works by checking model outputs against known hard-coded NSFW concepts.
127
+ The concepts are intentionally hidden to reduce the likelihood of reverse-engineering this filter.
128
+ Specifically, the checker compares the class probability of harmful concepts in the embedding space of the `CLIPTextModel` *after generation* of the images.
129
+ The concepts are passed into the model with the generated image and compared to a hand-engineered weight for each NSFW concept.
130
+
131
+
132
+ ## Training
133
+
134
+ **Training Data**
135
+ The model developers used the following dataset for training the model:
136
+
137
+ - LAION-2B (en) and subsets thereof (see next section)
138
+
139
+ **Training Procedure**
140
+ Stable Diffusion v1-4 is a latent diffusion model which combines an autoencoder with a diffusion model that is trained in the latent space of the autoencoder. During training,
141
+
142
+ - Images are encoded through an encoder, which turns images into latent representations. The autoencoder uses a relative downsampling factor of 8 and maps images of shape H x W x 3 to latents of shape H/f x W/f x 4
143
+ - Text prompts are encoded through a ViT-L/14 text-encoder.
144
+ - The non-pooled output of the text encoder is fed into the UNet backbone of the latent diffusion model via cross-attention.
145
+ - The loss is a reconstruction objective between the noise that was added to the latent and the prediction made by the UNet.
146
+
147
+ We currently provide four checkpoints, which were trained as follows.
148
+ - [`stable-diffusion-v1-1`](https://huggingface.co/CompVis/stable-diffusion-v1-1): 237,000 steps at resolution `256x256` on [laion2B-en](https://huggingface.co/datasets/laion/laion2B-en).
149
+ 194,000 steps at resolution `512x512` on [laion-high-resolution](https://huggingface.co/datasets/laion/laion-high-resolution) (170M examples from LAION-5B with resolution `>= 1024x1024`).
150
+ - [`stable-diffusion-v1-2`](https://huggingface.co/CompVis/stable-diffusion-v1-2): Resumed from `stable-diffusion-v1-1`.
151
+ 515,000 steps at resolution `512x512` on "laion-improved-aesthetics" (a subset of laion2B-en,
152
+ filtered to images with an original size `>= 512x512`, estimated aesthetics score `> 5.0`, and an estimated watermark probability `< 0.5`. The watermark estimate is from the LAION-5B metadata, the aesthetics score is estimated using an [improved aesthetics estimator](https://github.com/christophschuhmann/improved-aesthetic-predictor)).
153
+ - [`stable-diffusion-v1-3`](https://huggingface.co/CompVis/stable-diffusion-v1-3): Resumed from `stable-diffusion-v1-2`. 195,000 steps at resolution `512x512` on "laion-improved-aesthetics" and 10 % dropping of the text-conditioning to improve [classifier-free guidance sampling](https://arxiv.org/abs/2207.12598).
154
+ - [`stable-diffusion-v1-4`](https://huggingface.co/CompVis/stable-diffusion-v1-4) Resumed from `stable-diffusion-v1-2`.225,000 steps at resolution `512x512` on "laion-aesthetics v2 5+" and 10 % dropping of the text-conditioning to improve [classifier-free guidance sampling](https://arxiv.org/abs/2207.12598).
155
+
156
+ - **Hardware:** 32 x 8 x A100 GPUs
157
+ - **Optimizer:** AdamW
158
+ - **Gradient Accumulations**: 2
159
+ - **Batch:** 32 x 8 x 2 x 4 = 2048
160
+ - **Learning rate:** warmup to 0.0001 for 10,000 steps and then kept constant
161
+
162
+ ## Evaluation Results
163
+ Evaluations with different classifier-free guidance scales (1.5, 2.0, 3.0, 4.0,
164
+ 5.0, 6.0, 7.0, 8.0) and 50 PLMS sampling
165
+ steps show the relative improvements of the checkpoints:
166
+
167
+ ![pareto](https://huggingface.co/CompVis/stable-diffusion/resolve/main/v1-variants-scores.jpg)
168
+
169
+ Evaluated using 50 PLMS steps and 10000 random prompts from the COCO2017 validation set, evaluated at 512x512 resolution. Not optimized for FID scores.
170
+ ## Environmental Impact
171
+
172
+ **Stable Diffusion v1** **Estimated Emissions**
173
+ Based on that information, we estimate the following CO2 emissions using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700). The hardware, runtime, cloud provider, and compute region were utilized to estimate the carbon impact.
174
+
175
+ - **Hardware Type:** A100 PCIe 40GB
176
+ - **Hours used:** 150000
177
+ - **Cloud Provider:** AWS
178
+ - **Compute Region:** US-east
179
+ - **Carbon Emitted (Power consumption x Time x Carbon produced based on location of power grid):** 11250 kg CO2 eq.
180
+
181
+
182
+ ## Citation
183
+
184
+ ```bibtex
185
+ @InProceedings{Rombach_2022_CVPR,
186
+ author = {Rombach, Robin and Blattmann, Andreas and Lorenz, Dominik and Esser, Patrick and Ommer, Bj\"orn},
187
+ title = {High-Resolution Image Synthesis With Latent Diffusion Models},
188
+ booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
189
+ month = {June},
190
+ year = {2022},
191
+ pages = {10684-10695}
192
+ }
193
+ ```
194
+
195
+ *This model card was written by: Robin Rombach and Patrick Esser and is based on the [DALL-E Mini model card](https://huggingface.co/dalle-mini/dalle-mini).*