switch to os.walk, allow symlinks

This commit is contained in:
zappityzap 2024-11-01 20:19:12 -07:00
parent 3a92fa517b
commit 32c2bb3cb8

View File

@ -74,9 +74,13 @@ def natural_keys(text):
def get_available_models(): def get_available_models():
model_list = [] model_list = []
for item in list(Path(f'{shared.args.model_dir}/').glob('*')): for dirpath, dirnames, files in os.walk(shared.args.model_dir, followlinks=True):
if not item.name.endswith(('.txt', '-np', '.pt', '.json', '.yaml', '.py')) and 'llama-tokenizer' not in item.name: for file in files:
model_list.append(item.name) file_path = os.path.join(dirpath, file)
relative_path = os.path.relpath(file_path, shared.args.model_dir)
if not file.endswith(('.txt', '-np', '.pt', '.json', '.yaml', '.py')) and 'llama-tokenizer' not in file:
model_list.append(relative_path)
return ['None'] + sorted(model_list, key=natural_keys) return ['None'] + sorted(model_list, key=natural_keys)