Shekswess commited on
Commit
1a1657a
·
verified ·
1 Parent(s): 722aa92

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +14 -130
README.md CHANGED
@@ -3,8 +3,10 @@ license: openrail++
3
  tags:
4
  - text-to-image
5
  - stable-diffusion
 
 
6
  ---
7
- # SD-XL 1.0-base Model Card
8
  ![row01](01.png)
9
 
10
  ## Model
@@ -46,142 +48,21 @@ The chart above evaluates user preference for SDXL (with and without refinement)
46
  The SDXL base model performs significantly better than the previous variants, and the model combined with the refinement module achieves the best overall performance.
47
 
48
 
49
- ### 🧨 Diffusers
50
-
51
- Make sure to upgrade diffusers to >= 0.19.0:
52
- ```
53
- pip install diffusers --upgrade
54
- ```
55
-
56
- In addition make sure to install `transformers`, `safetensors`, `accelerate` as well as the invisible watermark:
57
- ```
58
- pip install invisible_watermark transformers accelerate safetensors
59
- ```
60
-
61
- To just use the base model, you can run:
62
-
63
- ```py
64
- from diffusers import DiffusionPipeline
65
- import torch
66
-
67
- pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
68
- pipe.to("cuda")
69
-
70
- # if using torch < 2.0
71
- # pipe.enable_xformers_memory_efficient_attention()
72
-
73
- prompt = "An astronaut riding a green horse"
74
-
75
- images = pipe(prompt=prompt).images[0]
76
- ```
77
-
78
- To use the whole base + refiner pipeline as an ensemble of experts you can run:
79
 
80
  ```py
81
- from diffusers import DiffusionPipeline
82
- import torch
83
-
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
-
99
- # Define how many steps and what % of steps to be run on each experts (80/20) here
100
- n_steps = 40
101
- high_noise_frac = 0.8
102
-
103
- prompt = "A majestic lion jumping from a big stone at night"
104
-
105
- # run both experts
106
- image = base(
107
- prompt=prompt,
108
- num_inference_steps=n_steps,
109
- denoising_end=high_noise_frac,
110
- output_type="latent",
111
- ).images
112
- image = refiner(
113
- prompt=prompt,
114
- num_inference_steps=n_steps,
115
- denoising_start=high_noise_frac,
116
- image=image,
117
- ).images[0]
118
- ```
119
 
120
- 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:
121
- ```py
122
- pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
123
- ```
124
 
125
- If you are limited by GPU VRAM, you can enable *cpu offloading* by calling `pipe.enable_model_cpu_offload`
126
- instead of `.to("cuda")`:
127
-
128
- ```diff
129
- - pipe.to("cuda")
130
- + pipe.enable_model_cpu_offload()
131
  ```
132
 
133
  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).
134
 
135
- ### Optimum
136
- [Optimum](https://github.com/huggingface/optimum) provides a Stable Diffusion pipeline compatible with both [OpenVINO](https://docs.openvino.ai/latest/index.html) and [ONNX Runtime](https://onnxruntime.ai/).
137
-
138
- #### OpenVINO
139
-
140
- To install Optimum with the dependencies required for OpenVINO :
141
-
142
- ```bash
143
- pip install optimum[openvino]
144
- ```
145
-
146
- To load an OpenVINO model and run inference with OpenVINO Runtime, you need to replace `StableDiffusionXLPipeline` with Optimum `OVStableDiffusionXLPipeline`. In case you want to load a PyTorch model and convert it to the OpenVINO format on-the-fly, you can set `export=True`.
147
-
148
- ```diff
149
- - from diffusers import StableDiffusionXLPipeline
150
- + from optimum.intel import OVStableDiffusionXLPipeline
151
-
152
- model_id = "stabilityai/stable-diffusion-xl-base-1.0"
153
- - pipeline = StableDiffusionXLPipeline.from_pretrained(model_id)
154
- + pipeline = OVStableDiffusionXLPipeline.from_pretrained(model_id)
155
- prompt = "A majestic lion jumping from a big stone at night"
156
- image = pipeline(prompt).images[0]
157
- ```
158
-
159
- You can find more examples (such as static reshaping and model compilation) in optimum [documentation](https://huggingface.co/docs/optimum/main/en/intel/inference#stable-diffusion-xl).
160
-
161
-
162
- #### ONNX
163
-
164
- To install Optimum with the dependencies required for ONNX Runtime inference :
165
-
166
- ```bash
167
- pip install optimum[onnxruntime]
168
- ```
169
-
170
- To load an ONNX model and run inference with ONNX Runtime, you need to replace `StableDiffusionXLPipeline` with Optimum `ORTStableDiffusionXLPipeline`. In case you want to load a PyTorch model and convert it to the ONNX format on-the-fly, you can set `export=True`.
171
-
172
- ```diff
173
- - from diffusers import StableDiffusionXLPipeline
174
- + from optimum.onnxruntime import ORTStableDiffusionXLPipeline
175
-
176
- model_id = "stabilityai/stable-diffusion-xl-base-1.0"
177
- - pipeline = StableDiffusionXLPipeline.from_pretrained(model_id)
178
- + pipeline = ORTStableDiffusionXLPipeline.from_pretrained(model_id)
179
- prompt = "A majestic lion jumping from a big stone at night"
180
- image = pipeline(prompt).images[0]
181
- ```
182
-
183
- You can find more examples in optimum [documentation](https://huggingface.co/docs/optimum/main/en/onnxruntime/usage_guides/models#stable-diffusion-xl).
184
-
185
 
186
  ## Uses
187
 
@@ -212,4 +93,7 @@ The model was not trained to be factual or true representations of people or eve
212
  - The autoencoding part of the model is lossy.
213
 
214
  ### Bias
215
- While the capabilities of image generation models are impressive, they can also reinforce or exacerbate social biases.
 
 
 
 
3
  tags:
4
  - text-to-image
5
  - stable-diffusion
6
+ - Neuron
7
+ - Inferentia
8
  ---
9
+ # SD-XL 1.0-base Model Card - Neuron
10
  ![row01](01.png)
11
 
12
  ## Model
 
48
  The SDXL base model performs significantly better than the previous variants, and the model combined with the refinement module achieves the best overall performance.
49
 
50
 
51
+ ### Usage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
  ```py
54
+ from diffusers import DPMSolverMultistepScheduler
55
+ from optimum.neuron import NeuronStableDiffusionXLPipeline
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
+ pipeline = NeuronStableDiffusionXLPipeline.from_pretrained("Shekswess/stable-diffusion-xl-base-1.0-neuron", device_ids=[0, 1])
58
+ pipeline.scheduler = DPMSolverMultistepScheduler.from_config(pipeline.scheduler.config)
 
 
59
 
60
+ prompt = "A swirling beautiful exploding scene of magical wonders and surreal ideas and objects with portraits of beautiful woman with silk back to camera, flowers, light, cosmic wonder, nebula, high-resolution"
61
+ image = pipeline(prompt=prompt).images[0].save("output.png)
 
 
 
 
62
  ```
63
 
64
  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).
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
  ## Uses
68
 
 
93
  - The autoencoding part of the model is lossy.
94
 
95
  ### Bias
96
+ While the capabilities of image generation models are impressive, they can also reinforce or exacerbate social biases.
97
+
98
+ ## Original Model
99
+ [Model](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0)