Skip to content

Commit

Permalink
[PEFT / LoRA] Fix civitai bug when network alpha is an empty dict (
Browse files Browse the repository at this point in the history
…huggingface#5608)

* fix civitai bug

* add test

* up

* fix test

* added slow test.

* style

* Update src/diffusers/utils/peft_utils.py

Co-authored-by: Benjamin Bossan <[email protected]>

* Update src/diffusers/utils/peft_utils.py

---------

Co-authored-by: Benjamin Bossan <[email protected]>
  • Loading branch information
younesbelkada and BenjaminBossan authored Nov 1, 2023
1 parent ffef55d commit 1be7e62
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion utils/peft_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def get_peft_kwargs(rank_dict, network_alpha_dict, peft_state_dict, is_unet=True
rank_pattern = dict(filter(lambda x: x[1] != r, rank_dict.items()))
rank_pattern = {k.split(".lora_B.")[0]: v for k, v in rank_pattern.items()}

if network_alpha_dict is not None:
if network_alpha_dict is not None and len(network_alpha_dict) > 0:
if len(set(network_alpha_dict.values())) > 1:
# get the alpha occuring the most number of times
lora_alpha = collections.Counter(network_alpha_dict.values()).most_common()[0][0]
Expand Down

0 comments on commit 1be7e62

Please sign in to comment.