You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It throws error : KeyError: 'to_k_lora.down.weight'
File "/workspace/server/tasks.py", line 346, in txt2img
self.pipe.unet.load_attn_procs(embd, use_safetensors=True)
File "/opt/conda/envs/ldm/lib/python3.8/site-packages/diffusers/loaders.py", line 224, in load_attn_procs
rank = value_dict["to_k_lora.down.weight"].shape[0]
KeyError: 'to_k_lora.down.weight'
Kohya-ss/sd-scripts has a nice mechanism for it, but it broke with 0.15, but you can for sure load A1111 LoRA Tensors with the function below on 0.14.0:
Kohya-ss/sd-scripts has a nice mechanism for it, but it broke with 0.15, but you can for sure load A1111 LoRA Tensors with the function below on 0.14.0:
@sayakpaul here you go. This Lora was trained using ss-kohya's scripts and works fine in A1111. I can load it on diffusers 0.14.0 with the snippet above using the lora.py from sd-scripts:
Reacted by Alejandro Gonzalez, Olexander, Rukia, AndrewHan0457, FunnyClown, Nicolas Martel, Haitao Zhou, yangrz, Zakaria Kasmi, Laura Johnson and 10 more
Reacted by Wok, WonJoong_Kim, Adhik Joshi and Maryam Maryam
Thanks @adhikjoshi! Getting a lot further with your function but the output is not matching what I would expect. As a first guess, I would think this is the alpha handling as that is hard-coded to 0.75 but the LoRA's I'm using have .alpha keys in them.
The same value is used on different layers, right? Say that I have initialized it with 1.0, then I just want to update it like multiplier = 0.75, updating everywhere it's referenced in the network.
I think you would need to fetch the multiplier appropriately from the corresponding state dict accordingly for that. Since the multiplier only concerns the weight modification part, I don't think reinitialization would be required here.
Hello, I'm using version v0.18 of Diffuser, and I managed to load a LoRa .safetensors file from CivitAI. However, I don't notice any changes even when I run lora:test:1.
Do you have any idea what could be causing this issue? Thank you in advance for your help.
@sonaterai I think there are some extra keys and corresponding weight parameters for which we don't have support yet. See #3087. It also links to a couple of other similar threads.
With SDXL old lora won't be working.
It's not supposed as the corresponding UNet is different as far as I understand.
@sonaterai I think there are some extra keys and corresponding weight parameters for which we don't have support yet. See #3087. It also links to a couple of other similar threads.
With SDXL old lora won't be working.
It's not supposed as the corresponding UNet is different as far as I understand.
If i train the Lora base on SDXL by myself, is that anything way to load the new Lora?
in my case in diffusers0.14.0, it gets wrong :
Traceback (most recent call last):
File "demo_txt2img.py", line 88, in
demo.loadEngines(args.engine_dir, args.onnx_dir, args.onnx_opset,
File "/workspace/demo/Diffusion/stable_diffusion_pipeline.py", line 288, in loadEngines
model = obj.get_model()
File "/workspace/demo/Diffusion/models.py", line 300, in get_model
return load_lora_weights(basic_unet, self.lora, "unet")
File "/workspace/demo/Diffusion/safetensors2bin.py", line 49, in load_lora_weights
temp_name += "_" + layer_infos.pop(0)
IndexError: pop from empty list
Activity
patrickvonplaten commentedon Apr 12, 2023
Hey @adhikjoshi,
Thanks for the issue we should indeed try to support also A1111 loading of LoRA tensors soon. cc @sayakpaul here
alejobrainz commentedon Apr 12, 2023
Kohya-ss/sd-scripts has a nice mechanism for it, but it broke with 0.15, but you can for sure load A1111 LoRA Tensors with the function below on 0.14.0:
but as of 0.15 it fails:
adhikjoshi commentedon Apr 12, 2023
CC @haofanwang @sayakpaul
sayakpaul commentedon Apr 13, 2023
Can someone provide LoRA file in the A1111 format? Providing as many relevant details associated to the file as possible would be great too.
adhikjoshi commentedon Apr 13, 2023
I have downloaded offset noise trained lora and uploaded its .safetensor on huggingface
https://huggingface.co/adhikjoshi/epi_noiseoffset
alejobrainz commentedon Apr 14, 2023
@sayakpaul here you go. This Lora was trained using ss-kohya's scripts and works fine in A1111. I can load it on diffusers 0.14.0 with the snippet above using the lora.py from sd-scripts:
caAos-000001.zip
Thanks,
Alejandro.
sayakpaul commentedon Apr 14, 2023
Cc: @patrickvonplaten ^
Fix regression introduced in huggingface#2448 (huggingface#2551)
adhikjoshi commentedon Apr 17, 2023
Here is function i made from convert_lora_safetensor_to_diffusers.py to load lora on inference time.
Can use it like,
@sayakpaul @patrickvonplaten
sayakpaul commentedon Apr 17, 2023
Thanks! Do you have the checkpoints with which we could test this?
adhikjoshi commentedon Apr 17, 2023
This uploaded safetensor lora and others work well
pdoane commentedon Apr 17, 2023
Thanks @adhikjoshi! Getting a lot further with your function but the output is not matching what I would expect. As a first guess, I would think this is the alpha handling as that is hard-coded to 0.75 but the LoRA's I'm using have .alpha keys in them.
63 remaining items
notdanilo commentedon Jun 29, 2023
The same value is used on different layers, right? Say that I have initialized it with 1.0, then I just want to update it like
multiplier = 0.75, updating everywhere it's referenced in the network.Is it something possible to achieve?
sayakpaul commentedon Jun 29, 2023
I think you would need to fetch the multiplier appropriately from the corresponding state dict accordingly for that. Since the multiplier only concerns the weight modification part, I don't think reinitialization would be required here.
sonaterai commentedon Jul 7, 2023
Hello, I'm using version v0.18 of Diffuser, and I managed to load a LoRa .safetensors file from CivitAI. However, I don't notice any changes even when I run lora:test:1.
Do you have any idea what could be causing this issue? Thank you in advance for your help.
adhikjoshi commentedon Jul 7, 2023
With SDXL old lora won't be working.
Any workarounds?
sayakpaul commentedon Jul 7, 2023
@sonaterai I think there are some extra keys and corresponding weight parameters for which we don't have support yet. See #3087. It also links to a couple of other similar threads.
It's not supposed as the corresponding UNet is different as far as I understand.
sanbuphy commentedon Jul 8, 2023
If i train the Lora base on SDXL by myself, is that anything way to load the new Lora?
sayakpaul commentedon Jul 8, 2023
You should be able to. If not, please open a new thread with a reproducible set of instructions.
kkwhale7 commentedon Sep 1, 2023
in my case in diffusers0.14.0, it gets wrong :
Traceback (most recent call last):
File "demo_txt2img.py", line 88, in
demo.loadEngines(args.engine_dir, args.onnx_dir, args.onnx_opset,
File "/workspace/demo/Diffusion/stable_diffusion_pipeline.py", line 288, in loadEngines
model = obj.get_model()
File "/workspace/demo/Diffusion/models.py", line 300, in get_model
return load_lora_weights(basic_unet, self.lora, "unet")
File "/workspace/demo/Diffusion/safetensors2bin.py", line 49, in load_lora_weights
temp_name += "_" + layer_infos.pop(0)
IndexError: pop from empty list
can u help me ? thx
sayakpaul commentedon Sep 1, 2023
Please use the
load_lora_weights()API for this (docs). We don't maintain that script, so, sadly cannot offer any support.kkwhale7 commentedon Sep 1, 2023
however, i want to load lora for my unet and clip, not for the pipeline(Because I reused TensorRT's code)
kkwhale7 commentedon Sep 1, 2023
@sayakpaul
nullarch commentedon Oct 2, 2023
I tried the load_lora_weights() but inference results are confuse. load_lora_weights load the text encoder params in the lora?
kkwhale7 commentedon Oct 2, 2023
yes , both clip and unet
alirezaomneky commentedon Dec 18, 2023
I am having a similar issue. When I run pipe.load_lora_weights("lora_model_id"), where lora_model_id is the path to my model, I simply get this error:
KeyError: 'lora.down.weight'
Does anyone know how to fix this issue?
sayakpaul commentedon Dec 19, 2023
Can you open a new issue with a reproducible code snippet?