Prevent overwriting existing keys in state_dict

Ensure new key is added only if it doesn't exist.
This commit is contained in:
azazeal04 2026-04-04 19:45:05 +02:00 committed by GitHub
parent a73ac772b5
commit 479536e34d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -37,7 +37,8 @@ def twinflow_z_image_lora_to_diffusers(state_dict):
for key in list(state_dict.keys()):
if "t_embedder_2" not in key and key.startswith("t_embedder."):
new_key = key.replace("t_embedder.", "t_embedder_2.", 1)
state_dict[new_key] = state_dict.pop(key)
if new_key not in state_dict:
state_dict[new_key] = state_dict.pop(key)
return state_dict
def convert_lora(sd):