Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
library_name: diffusers
|
3 |
+
base_model: segmind/SSD-1B
|
4 |
+
tags:
|
5 |
+
- lora
|
6 |
+
- text-to-image
|
7 |
+
license: openrail++
|
8 |
+
inference: false
|
9 |
+
---
|
10 |
+
|
11 |
+
# Latent Consistency Model (LCM) LoRA: SSD-Tiny
|
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 [`segmind/SSD-Tiny`]("https://huggingface.co/segmind/SSD-1B") 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-tiny**](https://huggingface.co/segmind/lcm-lora-ssd-tiny) | **62.7** |
|
23 |
+
| [lcm-lora-sdxl](https://huggingface.co/latent-consistency/lcm-lora-sdxl) | 197 |
|
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 |
+
Let's load the base model `segmind/SSD-Tiny` first. 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 = "segmind/SSD-Tiny"
|
46 |
+
adapter_id = "segmind/lcm-lora-ssd-tiny"
|
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 |
+
![SSD-Tiny LCM LoRA Image]()
|