|
--- |
|
library_name: peft |
|
base_model: segmind/tiny-sd |
|
pipeline_tag: text-to-image |
|
--- |
|
# Usage |
|
```python |
|
from peft import PeftModel |
|
from diffusers import LCMScheduler, AutoPipelineForText2Image |
|
|
|
model_id = "segmind/tiny-sd" |
|
adapter_id = "akameswa/lcm-lora-tiny-sd" |
|
|
|
pipe = AutoPipelineForText2Image.from_pretrained(model_id) |
|
pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config) |
|
pipe.to("cuda") |
|
|
|
PeftModel.from_pretrained(pipe.unet, adapter_id) |
|
|
|
prompt = "a dog wearing a knitted hat on the floor" |
|
image = pipe(prompt=prompt, num_inference_steps=4, guidance_scale=1.0).images[0] |
|
display(image) |
|
``` |
|
|
|
# Saving complete model |
|
```python |
|
pipe.fuse_lora(lora_scale=1.0) |
|
pipe.unload_lora_weights() |
|
|
|
for param in pipe.unet.parameters(): |
|
param.data = param.data.contiguous() |
|
|
|
pipe.save_pretrained("./lcm-tiny-sd") |
|
``` |