YuCollection commited on
Commit
b5f8828
·
verified ·
1 Parent(s): 2c368a0

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +162 -3
README.md CHANGED
@@ -1,3 +1,162 @@
1
- ---
2
- license: openrail++
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: openrail++
3
+ tags:
4
+ - text-to-image
5
+ - stable-diffusion
6
+ ---
7
+ # SD-XL 1.0-base Model Card
8
+
9
+ > **Note:** This repository is a **mirror** and **not** the original upstream source.
10
+ > The original model, weights, and documentation are developed and maintained by **Stability AI**.
11
+ >
12
+ > The model weights hosted here are **unmodified** and redistributed **as-is**.
13
+ > Only minor editorial changes to this README (e.g. formatting or clarification) have been made and do **not** affect the model, its behavior, or its licensing.
14
+ >
15
+ > The model is released under the **CreativeML Open RAIL++-M License**, which permits use and redistribution **subject to explicit use-based restrictions** (see *Attachment A*).
16
+ > A full copy of the license is included in this repository and applies to all distributions of the model and its derivatives.
17
+ >
18
+ > Users of this mirror are responsible for complying with all terms of the CreativeML Open RAIL++-M License.
19
+ >
20
+ > This repository is **not affiliated with or endorsed by Stability AI**.
21
+ > The maintainer is willing to cooperate in good faith with the original rights holder regarding reasonable requests.
22
+
23
+ ## Model
24
+
25
+ [SDXL](https://arxiv.org/abs/2307.01952) consists of an [ensemble of experts](https://arxiv.org/abs/2211.01324) pipeline for latent diffusion:
26
+ In a first step, the base model is used to generate (noisy) latents,
27
+ which are then further processed with a refinement model (available here: https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/) specialized for the final denoising steps.
28
+ Note that the base model can be used as a standalone module.
29
+
30
+ Alternatively, we can use a two-stage pipeline as follows:
31
+ First, the base model is used to generate latents of the desired output size.
32
+ In the second step, we use a specialized high-resolution model and apply a technique called SDEdit (https://arxiv.org/abs/2108.01073, also known as "img2img")
33
+ to the latents generated in the first step, using the same prompt. This technique is slightly slower than the first one, as it requires more function evaluations.
34
+
35
+ Source code is available at https://github.com/Stability-AI/generative-models .
36
+
37
+ ### Model Description
38
+
39
+ - **Developed by:** Stability AI
40
+ - **Model type:** Diffusion-based text-to-image generative model
41
+ - **License:** [CreativeML Open RAIL++-M License](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/LICENSE.md)
42
+ - **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 two fixed, pretrained text encoders ([OpenCLIP-ViT/G](https://github.com/mlfoundations/open_clip) and [CLIP-ViT/L](https://github.com/openai/CLIP/tree/main)).
43
+ - **Resources for more information:** Check out our [GitHub Repository](https://github.com/Stability-AI/generative-models) and the [SDXL report on arXiv](https://arxiv.org/abs/2307.01952).
44
+
45
+ ### Model Sources
46
+
47
+ For research purposes, we recommend our `generative-models` Github repository (https://github.com/Stability-AI/generative-models), which implements the most popular diffusion frameworks (both training and inference) and for which new functionalities like distillation will be added over time.
48
+ [Clipdrop](https://clipdrop.co/stable-diffusion) provides free SDXL inference.
49
+
50
+ - **Repository:** https://github.com/Stability-AI/generative-models
51
+ - **Demo:** https://clipdrop.co/stable-diffusion
52
+
53
+
54
+ ### 🧨 Diffusers
55
+
56
+ Make sure to upgrade diffusers to >= 0.19.0:
57
+ ```
58
+ pip install diffusers --upgrade
59
+ ```
60
+
61
+ In addition make sure to install `transformers`, `safetensors`, `accelerate` as well as the invisible watermark:
62
+ ```
63
+ pip install invisible_watermark transformers accelerate safetensors
64
+ ```
65
+
66
+ To just use the base model, you can run:
67
+
68
+ ```py
69
+ from diffusers import DiffusionPipeline
70
+ import torch
71
+ pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
72
+ pipe.to("cuda")
73
+ # if using torch < 2.0
74
+ # pipe.enable_xformers_memory_efficient_attention()
75
+ prompt = "An astronaut riding a green horse"
76
+ images = pipe(prompt=prompt).images[0]
77
+ ```
78
+
79
+ To use the whole base + refiner pipeline as an ensemble of experts you can run:
80
+
81
+ ```py
82
+ from diffusers import DiffusionPipeline
83
+ import torch
84
+ # load both base & refiner
85
+ base = DiffusionPipeline.from_pretrained(
86
+ "stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True
87
+ )
88
+ base.to("cuda")
89
+ refiner = DiffusionPipeline.from_pretrained(
90
+ "stabilityai/stable-diffusion-xl-refiner-1.0",
91
+ text_encoder_2=base.text_encoder_2,
92
+ vae=base.vae,
93
+ torch_dtype=torch.float16,
94
+ use_safetensors=True,
95
+ variant="fp16",
96
+ )
97
+ refiner.to("cuda")
98
+ # Define how many steps and what % of steps to be run on each experts (80/20) here
99
+ n_steps = 40
100
+ high_noise_frac = 0.8
101
+ prompt = "A majestic lion jumping from a big stone at night"
102
+ # run both experts
103
+ image = base(
104
+ prompt=prompt,
105
+ num_inference_steps=n_steps,
106
+ denoising_end=high_noise_frac,
107
+ output_type="latent",
108
+ ).images
109
+ image = refiner(
110
+ prompt=prompt,
111
+ num_inference_steps=n_steps,
112
+ denoising_start=high_noise_frac,
113
+ image=image,
114
+ ).images[0]
115
+ ```
116
+
117
+ When using `torch >= 2.0`, you can improve the inference speed by 20-30% with torch.compile. Simple wrap the unet with torch compile before running the pipeline:
118
+ ```py
119
+ pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
120
+ ```
121
+
122
+ If you are limited by GPU VRAM, you can enable *cpu offloading* by calling `pipe.enable_model_cpu_offload`
123
+ instead of `.to("cuda")`:
124
+
125
+ ```diff
126
+ - pipe.to("cuda")
127
+ + pipe.enable_model_cpu_offload()
128
+ ```
129
+
130
+ For more information on how to use Stable Diffusion XL with `diffusers`, please have a look at [the Stable Diffusion XL Docs](https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion/stable_diffusion_xl).
131
+
132
+
133
+ ## Uses
134
+
135
+ ### Direct Use
136
+
137
+ The model is intended for research purposes only. Possible research areas and tasks include
138
+
139
+ - Generation of artworks and use in design and other artistic processes.
140
+ - Applications in educational or creative tools.
141
+ - Research on generative models.
142
+ - Safe deployment of models which have the potential to generate harmful content.
143
+ - Probing and understanding the limitations and biases of generative models.
144
+
145
+ Excluded uses are described below.
146
+
147
+ ### Out-of-Scope Use
148
+
149
+ 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.
150
+
151
+ ## Limitations and Bias
152
+
153
+ ### Limitations
154
+
155
+ - The model does not achieve perfect photorealism
156
+ - The model cannot render legible text
157
+ - The model struggles with more difficult tasks which involve compositionality, such as rendering an image corresponding to “A red cube on top of a blue sphere”
158
+ - Faces and people in general may not be generated properly.
159
+ - The autoencoding part of the model is lossy.
160
+
161
+ ### Bias
162
+ While the capabilities of image generation models are impressive, they can also reinforce or exacerbate social biases.