kohya-ss / kohya-ss/sd-scripts
AssertionError: duplicated lora name when loading Lora via create_network_from_weights with diffusers 0.15
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.2k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
Hello, Official release for diffusers 0.15 just came out and loading Lora from create_network_from_weights in lora.py now results in the following error:
```
assert lora.lora_name not in names, f"duplicated lora name: {lora.lora_name}"
AssertionError: duplicated lora name: lora_unet_down_blocks_0_attentions_0_transformer_blocks_0_attn1_to_q
```
Here is the code that worked on diffusers 0.14:
```
def apply_lora(pipe, lora_path, weight:float = 1.0):
from safetensors.torch import load_file
from utils.lora import create_network_from_weights
import torch
vae = pipe.vae
text_encoder = pipe.text_encoder
unet = pipe.unet
lora_path = "./lora/" + lora_path
sd = load_file(lora_path)
lora_network, sd = create_network_from_weights(weight, None, vae, text_encoder, unet, sd)
lora_network.apply_to(text_encoder, unet)
lora_network.load_state_dict(sd)
lora_network.to("cuda", dtype=torch.float16)
```
Please advice on how to load safetensor Lora Models on Diffusers 0.15 pipelines.
Thanks!
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in lora.py at create_network_from_weights and reproduce the duplicated-name assertion with the provided apply_lora example and a Diffusers 0.15 pipeline. Compare the relevant loading behavior against Diffusers 0.14. Done means the reported LoRA model loads without the duplicate-name assertion on the newer pipeline.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100