mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-10 13:35:10 -05:00
further tweaks to model management
- Work around problem with OmegaConf.update() that prevented model names from containing periods. - Fix logic bug in !delete_model that didn't check for existence of model in config file.
This commit is contained in:
@@ -613,8 +613,6 @@ def import_diffuser_model(path_or_repo:str, gen, opt, completer)->str:
|
||||
description = model_description):
|
||||
print('** model failed to import')
|
||||
return None
|
||||
if input('Make this the default model? [n] ').startswith(('y','Y')):
|
||||
manager.set_default_model(model_name)
|
||||
return model_name
|
||||
|
||||
def import_ckpt_model(path_or_url:str, gen, opt, completer)->str:
|
||||
@@ -647,8 +645,6 @@ def import_ckpt_model(path_or_url:str, gen, opt, completer)->str:
|
||||
print('** model failed to import')
|
||||
return None
|
||||
|
||||
if input('Make this the default model? [n] ').startswith(('y','Y')):
|
||||
manager.set_model_default(model_name)
|
||||
return model_name
|
||||
|
||||
def _verify_load(model_name:str, gen)->bool:
|
||||
@@ -726,6 +722,9 @@ def del_config(model_name:str, gen, opt, completer):
|
||||
if model_name == current_model:
|
||||
print("** Can't delete active model. !switch to another model first. **")
|
||||
return
|
||||
if model_name not in gen.model_manager.config:
|
||||
print(f"** Unknown model {model_name}")
|
||||
return
|
||||
gen.model_manager.del_model(model_name)
|
||||
gen.model_manager.commit(opt.conf)
|
||||
print(f'** {model_name} deleted')
|
||||
|
||||
@@ -230,6 +230,9 @@ class ModelManager(object):
|
||||
Delete the named model.
|
||||
'''
|
||||
omega = self.config
|
||||
if model_name not in omega:
|
||||
print(f'** Unknown model {model_name}')
|
||||
return
|
||||
del omega[model_name]
|
||||
if model_name in self.stack:
|
||||
self.stack.remove(model_name)
|
||||
@@ -253,9 +256,8 @@ class ModelManager(object):
|
||||
|
||||
assert (clobber or model_name not in omega), f'attempt to overwrite existing model definition "{model_name}"'
|
||||
|
||||
if model_name not in omega:
|
||||
omega[model_name] = dict()
|
||||
OmegaConf.update(omega,model_name,model_attributes,merge=False)
|
||||
omega[model_name] = model_attributes
|
||||
|
||||
if 'weights' in omega[model_name]:
|
||||
omega[model_name]['weights'].replace('\\','/')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user