From 107ca6bf4798757f2ad6b3111a709bf28746c698 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Mon, 17 Jul 2023 07:26:05 -0400 Subject: [PATCH] expose model paths as absolute to web models API --- invokeai/backend/model_management/model_manager.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/invokeai/backend/model_management/model_manager.py b/invokeai/backend/model_management/model_manager.py index c62f42b88d..3a4f9c1e66 100644 --- a/invokeai/backend/model_management/model_manager.py +++ b/invokeai/backend/model_management/model_manager.py @@ -568,6 +568,9 @@ class ModelManager(object): 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) return models @@ -635,6 +638,11 @@ 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)