---
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)
Project Page: [https://subpath-linear-approx-model.github.io/](https://subpath-linear-approx-model.github.io/)
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.
---
More examples: