better lora enum

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2024-11-01 11:58:08 -04:00
parent c44cf1d6db
commit 3a633e539b
3 changed files with 7 additions and 9 deletions
+1
View File
@@ -29,6 +29,7 @@
- list diffusers remove duplicates
- fix legacy extensions access to shared objects
- fix diffusers load from folder
- fix lora enum logging on windows
- move dowwloads of some auxillary models to hfcache instead of models folder
## Update for 2024-10-29
+5 -8
View File
@@ -533,18 +533,14 @@ def network_MultiheadAttention_load_state_dict(self, *args, **kwargs):
def list_available_networks():
t0 = time.time()
available_networks.clear()
available_network_aliases.clear()
forbidden_network_aliases.clear()
available_network_hash_lookup.clear()
forbidden_network_aliases.update({"none": 1, "Addams": 1})
directories = []
if os.path.exists(shared.cmd_opts.lora_dir):
directories.append(shared.cmd_opts.lora_dir)
else:
if not os.path.exists(shared.cmd_opts.lora_dir):
shared.log.warning(f'LoRA directory not found: path="{shared.cmd_opts.lora_dir}"')
if os.path.exists(shared.cmd_opts.lyco_dir) and shared.cmd_opts.lyco_dir != shared.cmd_opts.lora_dir:
directories.append(shared.cmd_opts.lyco_dir)
def add_network(filename):
if not os.path.isfile(filename):
@@ -565,11 +561,12 @@ def list_available_networks():
except OSError as e: # should catch FileNotFoundError and PermissionError etc.
shared.log.error(f'LoRA: filename="{filename}" {e}')
candidates = list(files_cache.list_files(*directories, ext_filter=[".pt", ".ckpt", ".safetensors"]))
candidates = list(files_cache.list_files(shared.cmd_opts.lora_dir, ext_filter=[".pt", ".ckpt", ".safetensors"]))
with concurrent.futures.ThreadPoolExecutor(max_workers=shared.max_workers) as executor:
for fn in candidates:
executor.submit(add_network, fn)
shared.log.info(f'Available LoRAs: items={len(available_networks)} folders={len(forbidden_network_aliases)}')
t1 = time.time()
shared.log.info(f'Available LoRAs: path="{shared.cmd_opts.lora_dir}" items={len(available_networks)} folders={len(forbidden_network_aliases)} time={t1 - t0:.2f}')
def infotext_pasted(infotext, params): # pylint: disable=W0613
+1 -1
View File
@@ -14,7 +14,7 @@ def load_module(path):
module_spec = importlib.util.spec_from_file_location(os.path.basename(path), path)
module = importlib.util.module_from_spec(module_spec)
try:
if '/sd-extension-' in path or '/Lora' in path: # safe extensions without stdout intercept
if 'sd-extension-' in path or 'Lora' in path: # safe extensions without stdout intercept
module_spec.loader.exec_module(module)
else:
if debug: