multimodalart HF staff commited on
Commit
52c067b
1 Parent(s): 9f492ce

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +188 -0
README.md CHANGED
@@ -1,3 +1,191 @@
1
  ---
2
  license: creativeml-openrail-m
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: creativeml-openrail-m
3
+ tags:
4
+ - stable-diffusion
5
+ - text-to-image
6
+ library_name: "stable-diffusion"
7
+ extra_gated_prompt: |-
8
+ One more step before getting this model.
9
+ This model is open access and available to all, with a CreativeML OpenRAIL-M license further specifying rights and usage.
10
+ The CreativeML OpenRAIL License specifies:
11
+
12
+ 1. You can't use the model to deliberately produce nor share illegal or harmful outputs or content
13
+ 2. CompVis claims no rights on the outputs you generate, you are free to use them and are accountable for their use which must not go against the provisions set in the license
14
+ 3. You may re-distribute the weights and use the model commercially and/or as a service. If you do, please be aware you have to include the same use restrictions as the ones in the license and share a copy of the CreativeML OpenRAIL-M to all your users (please read the license entirely and carefully)
15
+ Please read the full license here: https://huggingface.co/spaces/CompVis/stable-diffusion-license
16
+
17
+ By clicking on "Access repository" below, you accept that your *contact information* (email address and username) can be shared with the model authors as well.
18
+
19
+ extra_gated_fields:
20
+ I have read the License and agree with its terms: checkbox
21
  ---
22
+
23
+ Stable Diffusion Inpainting is a latent text-to-image diffusion model capable of generating photo-realistic images given any text input, with the extra capability of inpainting the pictures by using a mask.
24
+
25
+ The **Stable-Diffusion-Inpainting** was initialized with the weights of the [Stable-Diffusion-v-1-2](https://steps/huggingface.co/CompVis/stable-diffusion-v-1-2-original). First 595k steps regular training, then 440k steps of inpainting training at resolution 512x512 on “laion-aesthetics v2 5+” and 10% dropping of the text-conditioning to improve classifier-free [classifier-free guidance sampling](https://arxiv.org/abs/2207.12598). For inpainting, the UNet has 5 additional input channels (4 for the encoded masked-image and 1 for the mask itself) whose weights were zero-initialized after restoring the non-inpainting checkpoint. During training, we generate synthetic masks and in 25% mask everything.
26
+
27
+ #### Download the weights
28
+ - [sd-v1-5-inpainting.ckpt](https://huggingface.co/runwayml/stable-diffusion-inpainting/resolve/main/sd-v1-5-inpainting.ckpt)
29
+
30
+ These weights are intended to be used with the original [RunwayML Stable Diffusion codebase](https://github.com/runwayml/stable-diffusion). If you are looking for the model to use with the 🧨Diffusers library, it is coming soon.
31
+
32
+ ## Model Details
33
+ - **Developed by:** Robin Rombach, Patrick Esser
34
+ - **Model type:** Diffusion-based text-to-image generation model
35
+ - **Language(s):** English
36
+ - **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.
37
+ - **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).
38
+ - **Resources for more information:** [GitHub Repository](https://github.com/CompVis/stable-diffusion), [Paper](https://arxiv.org/abs/2112.10752).
39
+ - **Cite as:**
40
+
41
+ @InProceedings{Rombach_2022_CVPR,
42
+ author = {Rombach, Robin and Blattmann, Andreas and Lorenz, Dominik and Esser, Patrick and Ommer, Bj\"orn},
43
+ title = {High-Resolution Image Synthesis With Latent Diffusion Models},
44
+ booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
45
+ month = {June},
46
+ year = {2022},
47
+ pages = {10684-10695}
48
+ }
49
+
50
+ # Uses
51
+
52
+ ## Direct Use
53
+ The model is intended for research purposes only. Possible research areas and
54
+ tasks include
55
+
56
+ - Safe deployment of models which have the potential to generate harmful content.
57
+ - Probing and understanding the limitations and biases of generative models.
58
+ - Generation of artworks and use in design and other artistic processes.
59
+ - Applications in educational or creative tools.
60
+ - Research on generative models.
61
+
62
+ Excluded uses are described below.
63
+
64
+ ### Misuse, Malicious Use, and Out-of-Scope Use
65
+ _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 v1_.
66
+
67
+
68
+ 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.
69
+ #### Out-of-Scope Use
70
+ 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.
71
+ #### Misuse and Malicious Use
72
+ Using the model to generate content that is cruel to individuals is a misuse of this model. This includes, but is not limited to:
73
+
74
+ - Generating demeaning, dehumanizing, or otherwise harmful representations of people or their environments, cultures, religions, etc.
75
+ - Intentionally promoting or propagating discriminatory content or harmful stereotypes.
76
+ - Impersonating individuals without their consent.
77
+ - Sexual content without consent of the people who might see it.
78
+ - Mis- and disinformation
79
+ - Representations of egregious violence and gore
80
+ - Sharing of copyrighted or licensed material in violation of its terms of use.
81
+ - Sharing content that is an alteration of copyrighted or licensed material in violation of its terms of use.
82
+
83
+ ## Limitations and Bias
84
+
85
+ ### Limitations
86
+
87
+ - The model does not achieve perfect photorealism
88
+ - The model cannot render legible text
89
+ - 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”
90
+ - Faces and people in general may not be generated properly.
91
+ - The model was trained mainly with English captions and will not work as well in other languages.
92
+ - The autoencoding part of the model is lossy
93
+ - The model was trained on a large-scale dataset
94
+ [LAION-5B](https://laion.ai/blog/laion-5b/) which contains adult material
95
+ and is not fit for product use without additional safety mechanisms and
96
+ considerations.
97
+ - 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.
98
+ 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.
99
+
100
+ ### Bias
101
+ While the capabilities of image generation models are impressive, they can also reinforce or exacerbate social biases.
102
+ Stable Diffusion v1 was trained on subsets of [LAION-2B(en)](https://laion.ai/blog/laion-5b/),
103
+ which consists of images that are primarily limited to English descriptions.
104
+ Texts and images from communities and cultures that use other languages are likely to be insufficiently accounted for.
105
+ This affects the overall output of the model, as white and western cultures are often set as the default. Further, the
106
+ ability of the model to generate content with non-English prompts is significantly worse than with English-language prompts.
107
+
108
+
109
+ ## Training
110
+
111
+ **Training Data**
112
+ The model developers used the following dataset for training the model:
113
+
114
+ - LAION-2B (en) and subsets thereof (see next section)
115
+
116
+ **Training Procedure**
117
+ Stable Diffusion v1 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,
118
+
119
+ - 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
120
+ - Text prompts are encoded through a ViT-L/14 text-encoder.
121
+ - The non-pooled output of the text encoder is fed into the UNet backbone of the latent diffusion model via cross-attention.
122
+ - The loss is a reconstruction objective between the noise that was added to the latent and the prediction made by the UNet.
123
+
124
+ We currently provide six checkpoints, `sd-v1-1.ckpt`, `sd-v1-2.ckpt` and `sd-v1-3.ckpt`, `sd-v1-4.ckpt`, `sd-v1-5.ckpt` and `sd-v1-5-inpainting.ckpt`
125
+ which were trained as follows,
126
+
127
+ - `sd-v1-1.ckpt`: 237k steps at resolution `256x256` on [laion2B-en](https://huggingface.co/datasets/laion/laion2B-en).
128
+ 194k steps at resolution `512x512` on [laion-high-resolution](https://huggingface.co/datasets/laion/laion-high-resolution) (170M examples from LAION-5B with resolution `>= 1024x1024`).
129
+ - `sd-v1-2.ckpt`: Resumed from `sd-v1-1.ckpt`.
130
+ 515k steps at resolution `512x512` on "laion-improved-aesthetics" (a subset of laion2B-en,
131
+ 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)).
132
+ - `sd-v1-3.ckpt`: Resumed from `sd-v1-2.ckpt`. 195k 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).
133
+ - `sd-v1-4.ckpt`: 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 [classifier-free guidance sampling](https://arxiv.org/abs/2207.12598).
134
+ - `sd-v1-5.ckpt`: Resumed from sd-v1-2.ckpt. 595k steps at resolution 512x512 on "laion-aesthetics v2 5+" and 10% dropping of the text-conditioning to improve classifier-free guidance sampling.
135
+ - `sd-v1-5-inpaint.ckpt`: Resumed from sd-v1-2.ckpt. 595k steps at resolution 512x512 on "laion-aesthetics v2 5+" and 10% dropping of the text-conditioning to improve classifier-free guidance sampling. Then 440k steps of inpainting training at resolution 512x512 on “laion-aesthetics v2 5+” and 10% dropping of the text-conditioning. For inpainting, the UNet has 5 additional input channels (4 for the encoded masked-image and 1 for the mask itself) whose weights were zero-initialized after restoring the non-inpainting checkpoint. During training, we generate synthetic masks and in 25% mask everything.
136
+
137
+
138
+ - **Hardware:** 32 x 8 x A100 GPUs
139
+ - **Optimizer:** AdamW
140
+ - **Gradient Accumulations**: 2
141
+ - **Batch:** 32 x 8 x 2 x 4 = 2048
142
+ - **Learning rate:** warmup to 0.0001 for 10,000 steps and then kept constant
143
+
144
+ ## Evaluation Results
145
+ Evaluations with different classifier-free guidance scales (1.5, 2.0, 3.0, 4.0,
146
+ 5.0, 6.0, 7.0, 8.0) and 50 PLMS sampling
147
+ steps show the relative improvements of the checkpoints:
148
+
149
+ ![pareto](https://huggingface.co/CompVis/stable-diffusion/resolve/main/v1-1-to-v1-5.png)
150
+
151
+ Evaluated using 50 PLMS steps and 10000 random prompts from the COCO2017 validation set, evaluated at 512x512 resolution. Not optimized for FID scores.
152
+
153
+ ## Inpainting Evaluation
154
+ To assess the performance of the inpainting model, we used the same evaluation
155
+ protocol as in our [LDM paper](https://arxiv.org/abs/2112.10752). Since the
156
+ Stable Diffusion Inpainting Model acccepts a text input, we simply used a fixed
157
+ prompt of `photograph of a beautiful empty scene, highest quality settings`.
158
+
159
+ | Model | FID | LPIPS |
160
+ |-----------------------------|------|------------------|
161
+ | Stable Diffusion Inpainting | 1.00 | 0.141 (+- 0.082) |
162
+ | Latent Diffusion Inpainting | 1.50 | 0.137 (+- 0.080) |
163
+ | CoModGAN | 1.82 | 0.15 |
164
+ | LaMa | 2.21 | 0.134 (+- 0.080) |
165
+
166
+ ## Environmental Impact
167
+
168
+ **Stable Diffusion v1** **Estimated Emissions**
169
+ 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.
170
+
171
+ - **Hardware Type:** A100 PCIe 40GB
172
+ - **Hours used:** 150000
173
+ - **Cloud Provider:** AWS
174
+ - **Compute Region:** US-east
175
+ - **Carbon Emitted (Power consumption x Time x Carbon produced based on location of power grid):** 11250 kg CO2 eq.
176
+
177
+
178
+ ## Citation
179
+
180
+ ```bibtex
181
+ @InProceedings{Rombach_2022_CVPR,
182
+ author = {Rombach, Robin and Blattmann, Andreas and Lorenz, Dominik and Esser, Patrick and Ommer, Bj\"orn},
183
+ title = {High-Resolution Image Synthesis With Latent Diffusion Models},
184
+ booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
185
+ month = {June},
186
+ year = {2022},
187
+ pages = {10684-10695}
188
+ }
189
+ ```
190
+
191
+ *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).*