From 56bd873d7a8e94c0689b250da4d0d410069efe49 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Fri, 23 Jun 2023 10:52:59 -0400 Subject: [PATCH] make relative model paths work in model manager --- invokeai/backend/model_management/model_manager.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/invokeai/backend/model_management/model_manager.py b/invokeai/backend/model_management/model_manager.py index 4e2c789c07..c7fb7569db 100644 --- a/invokeai/backend/model_management/model_manager.py +++ b/invokeai/backend/model_management/model_manager.py @@ -384,7 +384,8 @@ class ModelManager(object): # if it known model check that target path exists (if manualy deleted) else: # logic repeated twice(in rescan too) any way to optimize? - if not os.path.exists(self.models[model_key].path): + model_path = self.globals.root_path / self.models[model_key].path + if not model_path.exists(): if model_class.save_to_config: self.models[model_key].error = ModelError.NotFound raise Exception(f"Files for model \"{model_key}\" not found") @@ -395,13 +396,13 @@ class ModelManager(object): # reset model errors? - - model_config = self.models[model_key] # /models/{base_model}/{model_type}/{name}.ckpt or .safentesors # /models/{base_model}/{model_type}/{name}/ - model_path = model_config.path + # massage relative paths into absolute ones + model_path = model_path or self.globals.root_path / model_config.path + model_config.path = model_path # vae/movq override # TODO: @@ -415,7 +416,7 @@ class ModelManager(object): # TODO: path # TODO: is it accurate to use path as id - dst_convert_path = self.globals.models_dir / ".cache" / hashlib.md5(model_path.encode()).hexdigest() + dst_convert_path = self.globals.models_dir / ".cache" / hashlib.md5(str(model_path).encode()).hexdigest() model_path = model_class.convert_if_required( base_model=base_model, model_path=model_path,