aboutsummaryrefslogtreecommitdiff
path: root/modules/modelloader.py
diff options
context:
space:
mode:
authorAUTOMATIC <16777216c@gmail.com>2023-05-08 11:33:45 +0300
committerAUTOMATIC <16777216c@gmail.com>2023-05-08 11:33:45 +0300
commit083dc3c76ab7dbc7b2b04f3396d4f5280b002906 (patch)
tree2cc1ea2ab9cf9cb59655fae23a661868adfce871 /modules/modelloader.py
parent855f83f92c7f951683d3c664c58f4b37017b8d32 (diff)
directory hiding for extra networks: dirs starting with . will hide their cards on extra network tabs unless specifically searched for
create HTML for extra network pages only on demand allow directories starting with . to still list their models for lora, checkpoints, etc keep "search" filter for extra networks when user refreshes the page
Diffstat (limited to 'modules/modelloader.py')
-rw-r--r--modules/modelloader.py27
1 files changed, 8 insertions, 19 deletions
diff --git a/modules/modelloader.py b/modules/modelloader.py
index 522affc6..f2274488 100644
--- a/modules/modelloader.py
+++ b/modules/modelloader.py
@@ -22,9 +22,6 @@ def load_models(model_path: str, model_url: str = None, command_path: str = None
"""
output = []
- if ext_filter is None:
- ext_filter = []
-
try:
places = []
@@ -39,22 +36,14 @@ def load_models(model_path: str, model_url: str = None, command_path: str = None
places.append(model_path)
for place in places:
- if os.path.exists(place):
- for file in glob.iglob(place + '**/**', recursive=True):
- full_path = file
- if os.path.isdir(full_path):
- continue
- if os.path.islink(full_path) and not os.path.exists(full_path):
- print(f"Skipping broken symlink: {full_path}")
- continue
- if ext_blacklist is not None and any([full_path.endswith(x) for x in ext_blacklist]):
- continue
- if len(ext_filter) != 0:
- model_name, extension = os.path.splitext(file)
- if extension not in ext_filter:
- continue
- if file not in output:
- output.append(full_path)
+ for full_path in shared.walk_files(place, allowed_extensions=ext_filter):
+ if os.path.islink(full_path) and not os.path.exists(full_path):
+ print(f"Skipping broken symlink: {full_path}")
+ continue
+ if ext_blacklist is not None and any([full_path.endswith(x) for x in ext_blacklist]):
+ continue
+ if full_path not in output:
+ output.append(full_path)
if model_url is not None and len(output) == 0:
if download_name is not None: