File size: 1,953 Bytes
eb2a5e0 ecf0368 eb2a5e0 ecf0368 eb2a5e0 ecf0368 fb7ab9b ecf0368 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
---
library_name: diffusers
base_model: stabilityai/stable-diffusion-xl-base-1.0
tags:
- text-to-image
license: apache-2.0
inference: false
---
# Sub-path Linear Approximation Model (SLAM) LoRA: SDXL
Paper: [https://arxiv.org/abs/2404.13903](https://arxiv.org/abs/2404.13903)<br/>
Project Page: [https://subpath-linear-approx-model.github.io/](https://subpath-linear-approx-model.github.io/)<br/>
The checkpoint is a distilled from [stabilityai/stable-diffusion-xl-base-1.0](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0) with our proposed Sub-path Linear Approximation Model, which reduces the number of inference steps to only between 2-4 steps.
## Usage
First, install the latest version of the Diffusers library as well as peft, accelerate and transformers.
```bash
pip install --upgrade pip
pip install --upgrade diffusers transformers accelerate peft
```
We implement SLAM to be compatible with [LCMScheduler](https://huggingface.co/docs/diffusers/v0.22.3/en/api/schedulers/lcm#diffusers.LCMScheduler). You can use SLAM-LoRA just like you use LCM-LoRA.
```python
import torch
from diffusers import LCMScheduler, AutoPipelineForText2Image
model_id = "stabilityai/stable-diffusion-xl-base-1.0"
adapter_id = "alimama-creative/slam-lora-sdxl"
pipe = AutoPipelineForText2Image.from_pretrained(model_id, torch_dtype=torch.float16, variant="fp16")
pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
pipe.to("cuda")
# load and fuse lcm lora
pipe.load_lora_weights(adapter_id)
pipe.fuse_lora()
prompt = "A brown teddy bear holding a glass vase in front of a grave."
image = pipe(prompt=prompt, num_inference_steps=4, guidance_scale=1.0).images[0]
```
Compare with latent-consistency/lcm-lora-sdxl.
<img src='https://huggingface.co/alimama-creative/slam-lora-sdxl/resolve/main/sdxl_cmp.jpg'>
---
More examples:
<img src='https://huggingface.co/alimama-creative/slam-lora-sdxl/resolve/main/slam-lora-sdxl.jpg'>
|