reinitialize models.yaml if corrupt or missing

This commit is contained in:
Lincoln Stein 2023-07-20 11:26:20 -04:00
parent a2e2f0858d
commit b1a6ba552b
2 changed files with 9 additions and 2 deletions

View File

@ -23,6 +23,7 @@ from urllib import request
import npyscreen import npyscreen
import transformers import transformers
import omegaconf
from diffusers import AutoencoderKL from diffusers import AutoencoderKL
from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
from huggingface_hub import HfFolder from huggingface_hub import HfFolder
@ -568,7 +569,14 @@ def default_startup_options(init_file: Path) -> Namespace:
return opts return opts
def default_user_selections(program_opts: Namespace) -> InstallSelections: def default_user_selections(program_opts: Namespace) -> InstallSelections:
try:
installer = ModelInstall(config) 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() models = installer.all_models()
return InstallSelections( return InstallSelections(
install_models=[models[installer.default_model()].path or models[installer.default_model()].repo_id] install_models=[models[installer.default_model()].path or models[installer.default_model()].repo_id]

View File

@ -958,7 +958,6 @@ class ModelManager(object):
config.controlnet_dir, config.controlnet_dir,
] if x ] if x
} }
print(directories)
scanner = ScanAndImport(directories, self.logger, ignore=known_paths, installer=installer) scanner = ScanAndImport(directories, self.logger, ignore=known_paths, installer=installer)
scanner.search() scanner.search()