Commit
·
a56346e
0
Parent(s):
Duplicate from latent-consistency/lcm-lora-sdxl
Browse filesCo-authored-by: Suraj Patil <valhalla@users.noreply.huggingface.co>
- .gitattributes +36 -0
- LCM-LoRA-Technical-Report.pdf +3 -0
- README.md +87 -0
- pytorch_lora_weights.safetensors +3 -0
.gitattributes
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
LCM-LoRA-Technical-Report.pdf filter=lfs diff=lfs merge=lfs -text
|
LCM-LoRA-Technical-Report.pdf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:23f42605e848334d433996c92a5baa12280b18730e56455f58f85d8f2f28f160
|
3 |
+
size 1726518
|
README.md
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
library_name: diffusers
|
3 |
+
base_model: stabilityai/stable-diffusion-xl-base-1.0
|
4 |
+
tags:
|
5 |
+
- lora
|
6 |
+
- text-to-image
|
7 |
+
license: openrail++
|
8 |
+
inference: false
|
9 |
+
---
|
10 |
+
|
11 |
+
# Latent Consistency Model (LCM) LoRA: SDXL
|
12 |
+
|
13 |
+
Latent Consistency Model (LCM) LoRA was proposed in [LCM-LoRA: A universal Stable-Diffusion Acceleration Module](https://arxiv.org/abs/2311.05556)
|
14 |
+
by *Simian Luo, Yiqin Tan, Suraj Patil, Daniel Gu et al.*
|
15 |
+
|
16 |
+
It is a distilled consistency adapter for [`stable-diffusion-xl-base-1.0`](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0) that allows
|
17 |
+
to reduce the number of inference steps to only between **2 - 8 steps**.
|
18 |
+
|
19 |
+
| Model | Params / M |
|
20 |
+
|----------------------------------------------------------------------------|------------|
|
21 |
+
| [lcm-lora-sdv1-5](https://huggingface.co/latent-consistency/lcm-lora-sdv1-5) | 67.5 |
|
22 |
+
| [lcm-lora-ssd-1b](https://huggingface.co/latent-consistency/lcm-lora-ssd-1b) | 105 |
|
23 |
+
| [**lcm-lora-sdxl**](https://huggingface.co/latent-consistency/lcm-lora-sdxl) | **197M** |
|
24 |
+
|
25 |
+
## Usage
|
26 |
+
|
27 |
+
LCM-LoRA is supported in 🤗 Hugging Face Diffusers library from version v0.23.0 onwards. To run the model, first
|
28 |
+
install the latest version of the Diffusers library as well as `peft`, `accelerate` and `transformers`.
|
29 |
+
audio dataset from the Hugging Face Hub:
|
30 |
+
|
31 |
+
```bash
|
32 |
+
pip install --upgrade pip
|
33 |
+
pip install --upgrade diffusers transformers accelerate peft
|
34 |
+
```
|
35 |
+
|
36 |
+
### Text-to-Image
|
37 |
+
|
38 |
+
The adapter can be loaded with it's base model `stabilityai/stable-diffusion-xl-base-1.0`. Next, the scheduler needs to be changed to [`LCMScheduler`](https://huggingface.co/docs/diffusers/v0.22.3/en/api/schedulers/lcm#diffusers.LCMScheduler) and we can reduce the number of inference steps to just 2 to 8 steps.
|
39 |
+
Please make sure to either disable `guidance_scale` or use values between 1.0 and 2.0.
|
40 |
+
|
41 |
+
```python
|
42 |
+
import torch
|
43 |
+
from diffusers import LCMScheduler, AutoPipelineForText2Image
|
44 |
+
|
45 |
+
model_id = "stabilityai/stable-diffusion-xl-base-1.0"
|
46 |
+
adapter_id = "latent-consistency/lcm-lora-sdxl"
|
47 |
+
|
48 |
+
pipe = AutoPipelineForText2Image.from_pretrained(model_id, torch_dtype=torch.float16, variant="fp16")
|
49 |
+
pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
|
50 |
+
pipe.to("cuda")
|
51 |
+
|
52 |
+
# load and fuse lcm lora
|
53 |
+
pipe.load_lora_weights(adapter_id)
|
54 |
+
pipe.fuse_lora()
|
55 |
+
|
56 |
+
|
57 |
+
prompt = "Self-portrait oil painting, a beautiful cyborg with golden hair, 8k"
|
58 |
+
|
59 |
+
# disable guidance_scale by passing 0
|
60 |
+
image = pipe(prompt=prompt, num_inference_steps=4, guidance_scale=0).images[0]
|
61 |
+
```
|
62 |
+
|
63 |
+
![](./image.png)
|
64 |
+
|
65 |
+
### Image-to-Image
|
66 |
+
|
67 |
+
Works as well! TODO docs
|
68 |
+
|
69 |
+
### Inpainting
|
70 |
+
|
71 |
+
Works as well! TODO docs
|
72 |
+
|
73 |
+
### ControlNet
|
74 |
+
|
75 |
+
Works as well! TODO docs
|
76 |
+
|
77 |
+
### T2I Adapter
|
78 |
+
|
79 |
+
Works as well! TODO docs
|
80 |
+
|
81 |
+
## Speed Benchmark
|
82 |
+
|
83 |
+
TODO
|
84 |
+
|
85 |
+
## Training
|
86 |
+
|
87 |
+
TODO
|
pytorch_lora_weights.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c3dbf7eb26dd00ae6b6b95da69be9f1cb95a3b2c5bcf9be82323227a19b91329
|
3 |
+
size 393854624
|