mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-25 17:29:22 +01:00
Better way to sort the models/loras
This commit is contained in:
parent
7dfbe54f42
commit
ddbd237ec9
13
server.py
13
server.py
@ -40,11 +40,18 @@ if settings_file is not None:
|
||||
shared.settings[item] = new_settings[item]
|
||||
|
||||
|
||||
def special_sort(model_name):
|
||||
if '_' in model_name:
|
||||
return ('_'.join(model_name.split('_')[1:])).lower()
|
||||
else:
|
||||
return model_name.lower()
|
||||
|
||||
|
||||
def get_available_models():
|
||||
if shared.args.flexgen:
|
||||
return sorted([re.sub('-np$', '', item.name) for item in list(Path(f'{shared.args.model_dir}/').glob('*')) if item.name.endswith('-np')], key=str.lower)
|
||||
return sorted([re.sub('-np$', '', item.name) for item in list(Path(f'{shared.args.model_dir}/').glob('*')) if item.name.endswith('-np')], key=special_sort)
|
||||
else:
|
||||
return sorted([re.sub('.pth$', '', item.name) for item in list(Path(f'{shared.args.model_dir}/').glob('*')) if not item.name.endswith(('.txt', '-np', '.pt', '.json'))], key=str.lower)
|
||||
return sorted([re.sub('.pth$', '', item.name) for item in list(Path(f'{shared.args.model_dir}/').glob('*')) if not item.name.endswith(('.txt', '-np', '.pt', '.json'))], key=special_sort)
|
||||
|
||||
|
||||
def get_available_presets():
|
||||
@ -81,7 +88,7 @@ def get_available_softprompts():
|
||||
|
||||
|
||||
def get_available_loras():
|
||||
return ['None'] + sorted([item.name for item in list(Path(shared.args.lora_dir).glob('*')) if not item.name.endswith(('.txt', '-np', '.pt', '.json'))], key=str.lower)
|
||||
return ['None'] + sorted([item.name for item in list(Path(shared.args.lora_dir).glob('*')) if not item.name.endswith(('.txt', '-np', '.pt', '.json'))], key=special_sort)
|
||||
|
||||
|
||||
def load_model_wrapper(selected_model):
|
||||
|
Loading…
Reference in New Issue
Block a user