local Lora not loading

#7
by LolaRoseHB - opened

My local Lora is not loading. Here's the code :

from diffusers import StableDiffusion3Pipeline
import torch

model_id = "stabilityai/stable-diffusion-3.5-medium"

pipe = StableDiffusion3Pipeline.from_pretrained(
model_id,
low_cpu_mem_usage=False,
text_encoder_3=None,
tokenizer_3=None,
torch_dtype=torch.float32,
use_safetensors=True
)

lora = "my_sd35_lora"

pipe.load_lora_weights(
"/path/to/lora",
weight_name="my_sd35_lora.safetensors",
adapter_name=lora
)

pipe.set_adapters([lora], adapter_weights=[1.0])
pipe.fuse_lora()

image = pipe(
prompt="this is a prompt",
num_inference_steps=30
).images[0]

image.save("my_image.png", format="PNG")

EDIT:

I did get a HF (not local) lora working by making these changes.

installed:
pip install protobuf
pip install sentencepiece

added this code to previous example:
from torch import mps
import os

os.environ["PYTORCH_MPS_HIGH_WATERMARK_RATIO"] = "0.0"

pipe = StableDiffusion3Pipeline.from_pretrained(
"stabilityai/stable-diffusion-3.5-medium",
torch_dtype=torch.bfloat16
)

pipe.load_lora_weights(
"hugging-user/hf-SD3.5-LoRA",
weight_name="hf-SD3.5-LoRA.safetensors"
)

pipe.fuse_lora(lora_scale=1.0)
pipe.to("mps")

Sign up or log in to comment