Update README.md
Browse files
README.md
CHANGED
@@ -4,6 +4,44 @@ license: openrail++
|
|
4 |
|
5 |
This checkkpoint is compiled on [ByteDance/SDXL-Lightning](https://huggingface.co/ByteDance/SDXL-Lightning) for AWS Inf2.
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
```python
|
8 |
from optimum.neuron import NeuronStableDiffusionXLPipeline
|
9 |
from diffusers import EulerDiscreteScheduler
|
|
|
4 |
|
5 |
This checkkpoint is compiled on [ByteDance/SDXL-Lightning](https://huggingface.co/ByteDance/SDXL-Lightning) for AWS Inf2.
|
6 |
|
7 |
+
## Compilation
|
8 |
+
|
9 |
+
Download the unet checkpoint from [ByteDance/SDXL-Lightning](https://huggingface.co/ByteDance/SDXL-Lightning) and replace the unet checkpoint under the original sdxl checkpoint:
|
10 |
+
|
11 |
+
```python
|
12 |
+
from huggingface_hub import hf_hub_download
|
13 |
+
|
14 |
+
repo = "ByteDance/SDXL-Lightning"
|
15 |
+
ckpt = "sdxl_lightning_4step_unet.safetensors"
|
16 |
+
hf_hub_download(repo, ckpt)
|
17 |
+
```
|
18 |
+
|
19 |
+
Replace the unet:
|
20 |
+
|
21 |
+
```bash
|
22 |
+
cp /home/ubuntu/.cache/huggingface/hub/models--ByteDance--SDXL-Lightning/snapshots/xxxxxx/sdxl_lightning_4step_unet.safetensors stable-diffusion-xl-lightning/unet/diffusion_pytorch_model.safetensors
|
23 |
+
```
|
24 |
+
|
25 |
+
Compile the whole pipeline:
|
26 |
+
|
27 |
+
```python
|
28 |
+
from optimum.neuron import NeuronStableDiffusionXLPipeline
|
29 |
+
|
30 |
+
model_id = "stable-diffusion-xl-lightning"
|
31 |
+
num_images_per_prompt = 1
|
32 |
+
input_shapes = {"batch_size": 1, "height": 1024, "width": 1024, "num_images_per_prompt": num_images_per_prompt}
|
33 |
+
compiler_args = {"auto_cast": "matmul", "auto_cast_type": "bf16"}
|
34 |
+
|
35 |
+
stable_diffusion = NeuronStableDiffusionXLPipeline.from_pretrained(
|
36 |
+
model_id, export=True, **compiler_args, **input_shapes
|
37 |
+
)
|
38 |
+
save_directory = "sdxl_lightning_4_steps_neuronx/"
|
39 |
+
stable_diffusion.save_pretrained(save_directory)
|
40 |
+
# push to hub
|
41 |
+
```
|
42 |
+
|
43 |
+
## Inference
|
44 |
+
|
45 |
```python
|
46 |
from optimum.neuron import NeuronStableDiffusionXLPipeline
|
47 |
from diffusers import EulerDiscreteScheduler
|