Text-to-Image
Diffusers
lora
patrickvonplaten commited on
Commit
8e48c6c
1 Parent(s): c25e490

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +67 -13
README.md CHANGED
@@ -1,27 +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("segmind/SSD-1B", 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-ssd-1b")
18
  pipe.fuse_lora()
19
 
20
- pipe.to(device="cuda")
21
 
22
- prompt = "a red Porsche"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
- torch.manual_seed(0)
25
- # guidance_scale=1.0 to disable CFG
26
- image = pipe(prompt=prompt, num_inference_steps=4, guidance_scale=1.0).images[0]
27
- ```
 
1
  ---
2
+ library_name: diffusers
3
+ base_model: runwayml/stable-diffusion-v1-5
4
  tags:
5
  - lora
6
+ - text-to-image
7
+ license: openrail++
8
+ inference: false
9
  ---
10
 
11
+ # Latent Consistency Model (LCM) LoRA: SDv1-5
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 [`runwayml/stable-diffusion-v1-5`](https://huggingface.co/runwayml/stable-diffusion-v1-5) 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 SDv1-5 or deviratives. Here we use [`Lykon/dreamshaper-7`](https://huggingface.co/Lykon/dreamshaper-7). 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 = "Lykon/dreamshaper-7"
46
+ adapter_id = "latent-consistency/lcm-lora-sdv1-5"
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