Skip to content

Commit 7de51b8

Browse files
sayakpaulasomoza
andauthored
[lora] support more ZImage LoRAs (#12790)
up Co-authored-by: Álvaro Somoza <asomoza@users.noreply.github.com>
1 parent cd00ba6 commit 7de51b8

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/diffusers/loaders/lora_conversion_utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,6 +2417,17 @@ def convert_key(key: str) -> str:
24172417

24182418
state_dict = {convert_key(k): v for k, v in state_dict.items()}
24192419

2420+
def normalize_out_key(k: str) -> str:
2421+
if ".to_out" in k:
2422+
return k
2423+
return re.sub(
2424+
r"\.out(?=\.(?:lora_down|lora_up)\.weight$|\.alpha$)",
2425+
".to_out.0",
2426+
k,
2427+
)
2428+
2429+
state_dict = {normalize_out_key(k): v for k, v in state_dict.items()}
2430+
24202431
has_default = any("default." in k for k in state_dict)
24212432
if has_default:
24222433
state_dict = {k.replace("default.", ""): v for k, v in state_dict.items()}

0 commit comments

Comments
 (0)