From 201eb22d7650b00f55249c2646fa4f47ac3e0ec2 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Fri, 11 Nov 2022 04:41:02 +0000 Subject: [PATCH] prevent two models from being marked default in models.yaml --- ldm/invoke/model_cache.py | 9 ++++++--- scripts/invoke.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ldm/invoke/model_cache.py b/ldm/invoke/model_cache.py index 1999973ea8..d4007c46de 100644 --- a/ldm/invoke/model_cache.py +++ b/ldm/invoke/model_cache.py @@ -109,10 +109,13 @@ class ModelCache(object): Set the default model. The change will not take effect until you call model_cache.commit() ''' + print(f'DEBUG: before set_default_model()\n{OmegaConf.to_yaml(self.config)}') assert model_name in self.models,f"unknown model '{model_name}'" - for model in self.models: - self.models[model].pop('default',None) - self.models[model_name]['default'] = True + config = self.config + for model in config: + config[model].pop('default',None) + config[model_name]['default'] = True + print(f'DEBUG: after set_default_model():\n{OmegaConf.to_yaml(self.config)}') def list_models(self) -> dict: ''' diff --git a/scripts/invoke.py b/scripts/invoke.py index 50f995c26d..1c1d44dd16 100755 --- a/scripts/invoke.py +++ b/scripts/invoke.py @@ -584,7 +584,7 @@ def write_config_file(conf_path, gen, model_name, new_config, clobber=False, mak try: print('>> Verifying that new model loads...') - yaml_str = gen.model_cache.add_model(model_name, new_config, clobber) + gen.model_cache.add_model(model_name, new_config, clobber) assert gen.set_model(model_name) is not None, 'model failed to load' except AssertionError as e: print(f'** aborting **')