diff --git a/modules/shared.py b/modules/shared.py index fd0f226e..08268ae0 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -79,6 +79,7 @@ group.add_argument('--model', type=str, help='Name of the model to load by defau group.add_argument('--lora', type=str, nargs='+', help='The list of LoRAs to load. If you want to load more than one LoRA, write the names separated by spaces.') group.add_argument('--model-dir', type=str, default='models/', help='Path to directory with all the models.') group.add_argument('--lora-dir', type=str, default='loras/', help='Path to directory with all the loras.') +group.add_argument('--model-menu', action='store_true', help='Show a model menu in the terminal when the web UI is first launched.') group.add_argument('--settings', type=str, help='Load the default interface settings from this yaml file. See settings-template.yaml for an example. If you create a file called settings.yaml, this file will be loaded by default without the need to use the --settings flag.') group.add_argument('--extensions', type=str, nargs='+', help='The list of extensions to load. If you want to load more than one extension, write the names separated by spaces.') group.add_argument('--verbose', action='store_true', help='Print the prompts to the terminal.') diff --git a/server.py b/server.py index a4b6e3e3..1d261566 100644 --- a/server.py +++ b/server.py @@ -214,10 +214,28 @@ if __name__ == "__main__": if extension not in shared.args.extensions: shared.args.extensions.append(extension) + available_models = utils.get_available_models() + # Model defined through --model if shared.args.model is not None: shared.model_name = shared.args.model + # Select the model from a command-line menu + elif shared.args.model_menu: + if len(available_models) == 0: + logger.error('No models are available! Please download at least one.') + sys.exit(0) + else: + print('The following models are available:\n') + for i, model in enumerate(available_models): + print(f'{i+1}. {model}') + + print(f'\nWhich one do you want to load? 1-{len(available_models)}\n') + i = int(input()) - 1 + print() + + shared.model_name = available_models[i] + # If any model has been selected, load it if shared.model_name != 'None': p = Path(shared.model_name)