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,10 +74,14 @@ def natural_keys(text):
def get_available_models():
model_list = []
for item in list(Path(f'{shared.args.model_dir}/').glob('*')):
if not item.name.endswith(('.txt', '-np', '.pt', '.json', '.yaml', '.py')) and 'llama-tokenizer' not in item.name:
model_list.append(item.name)
for dirpath, dirnames, files in os.walk(shared.args.model_dir, followlinks=True):
for file in files:
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)