From b1a6ba552bd15cbfe0ebb3ed540c6273c79da45c Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Thu, 20 Jul 2023 11:26:20 -0400 Subject: [PATCH] reinitialize models.yaml if corrupt or missing --- invokeai/backend/install/invokeai_configure.py | 10 +++++++++- invokeai/backend/model_management/model_manager.py | 1 - 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/invokeai/backend/install/invokeai_configure.py b/invokeai/backend/install/invokeai_configure.py index 17c85df549..490f567642 100755 --- a/invokeai/backend/install/invokeai_configure.py +++ b/invokeai/backend/install/invokeai_configure.py @@ -23,6 +23,7 @@ from urllib import request import npyscreen import transformers +import omegaconf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker from huggingface_hub import HfFolder @@ -568,7 +569,14 @@ def default_startup_options(init_file: Path) -> Namespace: return opts def default_user_selections(program_opts: Namespace) -> InstallSelections: - installer = ModelInstall(config) + + try: + installer = ModelInstall(config) + except omegaconf.errors.ConfigKeyError: + logger.warning('Your models.yaml file is corrupt or out of date. Reinitializing') + initialize_rootdir(config.root_path, True) + installer = ModelInstall(config) + models = installer.all_models() return InstallSelections( install_models=[models[installer.default_model()].path or models[installer.default_model()].repo_id] diff --git a/invokeai/backend/model_management/model_manager.py b/invokeai/backend/model_management/model_manager.py index 02ffd2124a..e9baa5ca67 100644 --- a/invokeai/backend/model_management/model_manager.py +++ b/invokeai/backend/model_management/model_manager.py @@ -958,7 +958,6 @@ class ModelManager(object): config.controlnet_dir, ] if x } - print(directories) scanner = ScanAndImport(directories, self.logger, ignore=known_paths, installer=installer) scanner.search()