Fix lora issue.

This commit is contained in:
comfyanonymous 2024-09-08 10:10:47 -04:00
parent a5da4d0b3e
commit 9c5fca75f4
1 changed files with 7 additions and 5 deletions

View File

@ -248,15 +248,17 @@ def model_lora_keys_clip(model, key_map={}):
for k in sdk: for k in sdk:
if k.endswith(".weight"): if k.endswith(".weight"):
if k.startswith("t5xxl.transformer."):#OneTrainer SD3 and Flux lora if k.startswith("t5xxl.transformer."):#OneTrainer SD3 and Flux lora
l_key = k[len("t5xxl.transformer."):-len(".weight")]
t5_index = 1 t5_index = 1
if clip_l_present:
t5_index += 1
if clip_g_present: if clip_g_present:
t5_index += 1 t5_index += 1
if clip_l_present:
t5_index += 1
if t5_index == 2:
key_map["lora_te{}_{}".format(t5_index, l_key.replace(".", "_"))] = k #OneTrainer Flux
t5_index += 1
l_key = k[len("t5xxl.transformer."):-len(".weight")] key_map["lora_te{}_{}".format(t5_index, l_key.replace(".", "_"))] = k
lora_key = "lora_te{}_{}".format(t5_index, l_key.replace(".", "_"))
key_map[lora_key] = k
elif k.startswith("hydit_clip.transformer.bert."): #HunyuanDiT Lora elif k.startswith("hydit_clip.transformer.bert."): #HunyuanDiT Lora
l_key = k[len("hydit_clip.transformer.bert."):-len(".weight")] l_key = k[len("hydit_clip.transformer.bert."):-len(".weight")]
lora_key = "lora_te1_{}".format(l_key.replace(".", "_")) lora_key = "lora_te1_{}".format(l_key.replace(".", "_"))