Text-to-Image
Diffusers
Safetensors
patrickvonplaten commited on
Commit
453ec3d
1 Parent(s): 94db4f8

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +66 -5
README.md CHANGED
@@ -1,13 +1,74 @@
1
- ```py
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  from diffusers import UNet2DConditionModel, DiffusionPipeline, LCMScheduler
3
 
4
- unet = UNet2DConditionModel.from_pretrained("latent-consistency/lcm-ssd-1b", torch_dtype=torch.float16, variant="fp16")
5
- pipe = DiffusionPipeline.from_pretrained("segmind/SSD-1B", unet=unet, torch_dtype=torch.float16, variant="fp16")
6
 
7
  pipe.scheduler = LCMScheduler.from_config(sd_pipe.scheduler.config)
8
- pipe.set_progress_bar_config(disable=None)
9
 
10
  prompt = "a red car standing on the side of the street"
11
 
12
  image = pipe(prompt, num_inference_steps=4, guidance_scale=8.0).images[0]
13
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: diffusers
3
+ base_model: stabilityai/stable-diffusion-xl-base-1.0
4
+ tags:
5
+ - text-to-image
6
+ license: openrail++
7
+ inference: false
8
+ ---
9
+
10
+ # Latent Consistency Model (LCM): SDXL
11
+
12
+ Latent Consistency Model (LCM) was proposed in [Latent Consistency Models: Synthesizing High-Resolution Images with Few-Step Inference](https://arxiv.org/abs/2310.04378)
13
+ by *Simian Luo, Yiqin Tan et al.* and [Simian Luo](https://huggingface.co/SimianLuo), [Suraj Patil](https://huggingface.co/valhalla), and [Daniel Gu](https://huggingface.co/dg845)
14
+ succesfully applied the same approach to create LCM for SDXL.
15
+
16
+ This checkpoint is a LCM distilled version of [`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
+
20
+ ## Usage
21
+
22
+ LCM SDXL is supported in 🤗 Hugging Face Diffusers library from version v0.23.0 onwards. To run the model, first
23
+ install the latest version of the Diffusers library as well as `peft`, `accelerate` and `transformers`.
24
+ audio dataset from the Hugging Face Hub:
25
+
26
+ ```bash
27
+ pip install --upgrade pip
28
+ pip install --upgrade diffusers transformers accelerate peft
29
+ ```
30
+
31
+ ### Text-to-Image
32
+
33
+ The model can be loaded with it's base pipeline `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.
34
+ Please make sure to either disable `guidance_scale` or use values between 1.0 and 2.0.
35
+
36
+ ```python
37
  from diffusers import UNet2DConditionModel, DiffusionPipeline, LCMScheduler
38
 
39
+ unet = UNet2DConditionModel.from_pretrained("latent-consistency/lcm-sdxl", torch_dtype=torch.float16, variant="fp16")
40
+ pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", unet=unet, torch_dtype=torch.float16, variant="fp16")
41
 
42
  pipe.scheduler = LCMScheduler.from_config(sd_pipe.scheduler.config)
43
+ pipe.to("cuda")
44
 
45
  prompt = "a red car standing on the side of the street"
46
 
47
  image = pipe(prompt, num_inference_steps=4, guidance_scale=8.0).images[0]
48
+ ```
49
+
50
+ ![](./image.png)
51
+
52
+ ### Image-to-Image
53
+
54
+ Works as well! TODO docs
55
+
56
+ ### Inpainting
57
+
58
+ Works as well! TODO docs
59
+
60
+ ### ControlNet
61
+
62
+ Works as well! TODO docs
63
+
64
+ ### T2I Adapter
65
+
66
+ Works as well! TODO docs
67
+
68
+ ## Speed Benchmark
69
+
70
+ TODO
71
+
72
+ ## Training
73
+
74
+ TODO