I tried to use load_and_fuse_lora function with lora scale parameter but don't see an effect on the results - using lora scale equal to 0/0.5/1, creates the same results.
Example code:
from onediffx.lora import load_and_fuse_lora, unfuse_lora
import torch
from PIL import Image
from diffusers import AutoPipelineForImage2Image, StableDiffusionPipeline, AutoencoderKL, DiffusionPipeline
def run_inference(model_id, pipe, model_params):
load_and_fuse_lora(pipe, model_id, lora_scale=model_params['lora_scale'])
res = pipe(**model_params).images
unfuse_lora(pipe)
pipe.unload_lora_weights()
torch.cuda.empty_cache()
return res
def main():
device = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
dtype = torch.float16 if device != "cpu" else torch.float32
vae = AutoencoderKL.from_pretrained('sdxl-vae-fp16-fix', torch_dtype=dtype)
pipe = AutoPipelineForImage2Image.from_pretrained('stable-diffusion-xl-base-1.0', variant='fp16', vae=vae, torch_dtype=dtype).to(device)
if torch.cuda.is_available():
from onediffx import compile_pipe
pipe = compile_pipe(pipe, ignores=("vae.encoder", "vae.decoder"))
# warmup
pipe(prompt="prompt",
negative_prompt="negative_prompt",
num_inference_steps=5,
width=128,
height=128,
num_images_per_prompt=1,
image=Image.open('ref_img.png'))
model_params = {"prompt": "woman wearing pink dress'",
"negative_prompt": "Ugly, Dots",
"num_images_per_prompt": 1,
"num_inference_steps": 50,
"width": 1024,
"height": 1024,
"lora_scale": 0.5
}
res = run_inference("nerijs/pixel-art-xl", pipe, model_params)
if __name__ == "__main__":
main()
I added pipe.unload_lora_weights() after unfuse because without it, from run to run, the picture became more and more like gibberish
I tried to use load_and_fuse_lora function with lora scale parameter but don't see an effect on the results - using lora scale equal to 0/0.5/1, creates the same results.
Example code:
I added pipe.unload_lora_weights() after unfuse because without it, from run to run, the picture became more and more like gibberish