If only 1 model is available, load that model

This commit is contained in:
oobabooga 2023-04-13 11:44:10 -03:00
parent 8b482b4127
commit fbb448ce4f

View File

@ -441,16 +441,19 @@ else:
if extension not in shared.args.extensions: if extension not in shared.args.extensions:
shared.args.extensions.append(extension) shared.args.extensions.append(extension)
# Default model # Model defined through --model
if shared.args.model is not None: if shared.args.model is not None:
shared.model_name = shared.args.model shared.model_name = shared.args.model
shared.model, shared.tokenizer = load_model(shared.model_name)
# Only one model is available
elif len(available_models) == 1:
shared.model_name = available_models[0]
# Select the model from a command-line menu
elif shared.args.model_menu: elif shared.args.model_menu:
if len(available_models) == 0: if len(available_models) == 0:
print('No models are available! Please download at least one.') print('No models are available! Please download at least one.')
sys.exit(0) sys.exit(0)
elif len(available_models) == 1:
i = 0
else: else:
print('The following models are available:\n') print('The following models are available:\n')
for i, model in enumerate(available_models): for i, model in enumerate(available_models):
@ -459,9 +462,11 @@ elif shared.args.model_menu:
i = int(input()) - 1 i = int(input()) - 1
print() print()
shared.model_name = available_models[i] shared.model_name = available_models[i]
shared.model, shared.tokenizer = load_model(shared.model_name)
if shared.args.model is not None and shared.args.lora: # If any model has been selected, load it
if shared.model_name != 'None':
shared.model, shared.tokenizer = load_model(shared.model_name)
if shared.args.lora:
add_lora_to_model(shared.args.lora) add_lora_to_model(shared.args.lora)
# Default UI settings # Default UI settings