From a50fad15f1bdb2449d58588927afb1ae4829e27a Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Mon, 17 Jul 2023 07:16:45 -0400 Subject: [PATCH] absolutize model paths returned by the web API --- invokeai/backend/model_management/model_manager.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/invokeai/backend/model_management/model_manager.py b/invokeai/backend/model_management/model_manager.py index c62f42b88d..b426bcc0f7 100644 --- a/invokeai/backend/model_management/model_manager.py +++ b/invokeai/backend/model_management/model_manager.py @@ -567,6 +567,9 @@ class ModelManager(object): base_model=cur_base_model, model_type=cur_model_type, ) + # expose paths as absolute + if path := model_dict.get('path'): + model_dict['path'] = str(self.app_config.root_path / path) models.append(model_dict) @@ -635,7 +638,12 @@ class ModelManager(object): The returned dict has the same format as the dict returned by model_info(). """ - + # relativize paths as they go in - this makes it easier to move the root directory around + self.logger.debug(model_attributes) + if path := model_attributes.get('path'): + if Path(path).is_relative_to(self.app_config.root_path): + model_attributes['path'] = str(Path(path).relative_to(self.app_config.root_path)) + model_class = MODEL_CLASSES[base_model][model_type] model_config = model_class.create_config(**model_attributes) model_key = self.create_key(model_name, base_model, model_type)