Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Fix text encoder lora loading for wrapped models (#12852)

Jukka Seppänen06f85e2c792c
diff --git a/comfy/lora.py b/comfy/lora.py
index f36ddb046..63ee85323 100644
--- a/comfy/lora.py
+++ b/comfy/lora.py
@@ -99,6 +99,9 @@ def model_lora_keys_clip(model, key_map={}):
for k in sdk:
if k.endswith(".weight"):
key_map["text_encoders.{}".format(k[:-len(".weight")])] = k #generic lora format without any weird key names
+ tp = k.find(".transformer.") #also map without wrapper prefix for composite text encoder models
+ if tp > 0 and not k.startswith("clip_"):
+ key_map["text_encoders.{}".format(k[tp + 1:-len(".weight")])] = k
text_model_lora_key = "lora_te_text_model_encoder_layers_{}_{}"
clip_l_present = False