patrickvonplaten commited on
Commit
d4af770
1 Parent(s): 10442db

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +66 -13
README.md CHANGED
@@ -1,28 +1,81 @@
1
  ---
2
- library_name: peft
 
3
  tags:
4
  - lora
 
 
 
5
  ---
6
 
7
- ```py
8
- from diffusers import LCMScheduler, DiffusionPipeline
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  import torch
10
- import PIL.Image
11
- import requests
 
 
12
 
13
- pipe = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16, variant="fp16")
14
  pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
 
15
 
16
  # load and fuse lcm lora
17
- pipe.load_lora_weights("latent-consistency/lcm-lora-sdv1-5")
18
  pipe.fuse_lora()
19
 
20
- pipe.to(device="cuda")
21
 
22
- prompt = "a red Porsche"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
- torch.manual_seed(0)
25
 
26
- # make sure to use `guidance_scale=1.0` to disable CFG
27
- image = pipe(prompt=prompt, num_inference_steps=4, guidance_scale=1.0).images[0]
28
- ```
 
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](TODO:)
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`](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-to-Image
64
+
65
+ Works as well! TODO docs
66
+
67
+ ### Inpainting
68
+
69
+ Works as well! TODO docs
70
+
71
+ ### ControlNet
72
+
73
+ Works as well! TODO docs
74
+
75
+ ### T2I Adapter
76
+
77
+ Works as well! TODO docs
78
 
79
+ ## Training
80
 
81
+ TODO