tools / fuse_unfuse.py
patrickvonplaten's picture
all
6c27fdd
raw
history blame
651 Bytes
#!/usr/bin/env python3
import torch
from diffusers import StableDiffusionXLPipeline
pipe = StableDiffusionXLPipeline.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
torch_dtype=torch.float16,
).to("cuda")
#Fuse/unfuse first LoRA
pipe.load_lora_weights("joachimsallstrom/aether-cloud-lora-for-sdxl")
pipe.fuse_lora()
pipe.unload_lora_weights()
pipe.unfuse_lora()
#Now it would be expected that the the LoRA has been unfused and `pipe` in the its original state, however...
#Fuse/unfuse second LoRA
pipe.load_lora_weights("jbilcke-hf/sdxl-zelda64")
pipe.fuse_lora()
pipe.unload_lora_weights()
pipe.unfuse_lora() #errors out