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.

Support format for embeddings bundled in loras.

comfyanonymous1c08bf35b498
diff --git a/comfy/sd1_clip.py b/comfy/sd1_clip.py
index d32121d1b..6f3a7fd9a 100644
--- a/comfy/sd1_clip.py
+++ b/comfy/sd1_clip.py
@@ -313,6 +313,20 @@ def expand_directory_list(directories):
dirs.add(root)
return list(dirs)
+def bundled_embed(embed, key): #bundled embedding in lora format
+ i = 0
+ out_list = []
+ while True:
+ i += 1
+ k = key.format(i)
+ w = embed.get(k, None)
+ if w is None:
+ break
+ else:
+ out_list.append(w)
+
+ return torch.cat(out_list, dim=0)
+
def load_embed(embedding_name, embedding_directory, embedding_size, embed_key=None):
if isinstance(embedding_directory, str):
embedding_directory = [embedding_directory]
@@ -378,6 +392,10 @@ def load_embed(embedding_name, embedding_directory, embedding_size, embed_key=No
embed_out = torch.cat(out_list, dim=0)
elif embed_key is not None and embed_key in embed:
embed_out = embed[embed_key]
+ elif 'bundle_emb.place1.string_to_param.*' in embed:
+ embed_out = bundled_embed(embed, 'bundle_emb.place{}.string_to_param.*')
+ elif 'bundle_emb.place1.{}'.format(embed_key) in embed:
+ embed_out = bundled_embed(embed, 'bundle_emb.place{}.{}'.format('{}', embed_key))
else:
values = embed.values()
embed_out = next(iter(values))