Search recursively in subfolders for embeddings.

This commit is contained in:
comfyanonymous 2023-05-05 01:28:48 -04:00
parent 6ee11d7bc0
commit af9cc1fb6a

View File

@ -191,11 +191,20 @@ def safe_load_embed_zip(embed_path):
del embed
return out
def expand_directory_list(directories):
dirs = set()
for x in directories:
dirs.add(x)
for root, subdir, file in os.walk(x, followlinks=True):
dirs.add(root)
return list(dirs)
def load_embed(embedding_name, embedding_directory):
if isinstance(embedding_directory, str):
embedding_directory = [embedding_directory]
embedding_directory = expand_directory_list(embedding_directory)
valid_file = None
for embed_dir in embedding_directory:
embed_path = os.path.join(embed_dir, embedding_name)