From 52274087f3ce7253137feb6ebd9de9b603eff6bd Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Thu, 12 Oct 2023 21:23:29 -0400 Subject: [PATCH 1/2] close #4536 --- invokeai/app/api/routers/models.py | 1 + invokeai/backend/install/model_install_backend.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/invokeai/app/api/routers/models.py b/invokeai/app/api/routers/models.py index ebc40f5ce5..cb0832735b 100644 --- a/invokeai/app/api/routers/models.py +++ b/invokeai/app/api/routers/models.py @@ -152,6 +152,7 @@ async def import_model( ) -> ImportModelResponse: """Add a model using its local path, repo_id, or remote URL. Model characteristics will be probed and configured automatically""" + location = location.strip() items_to_import = {location} prediction_types = {x.value: x for x in SchedulerPredictionType} logger = ApiDependencies.invoker.services.logger diff --git a/invokeai/backend/install/model_install_backend.py b/invokeai/backend/install/model_install_backend.py index 1481300c77..bd26a7aa07 100644 --- a/invokeai/backend/install/model_install_backend.py +++ b/invokeai/backend/install/model_install_backend.py @@ -236,9 +236,16 @@ class ModelInstall(object): if not models_installed: models_installed = dict() + model_path_id_or_url = str(model_path_id_or_url).strip() + # A little hack to allow nested routines to retrieve info on the requested ID self.current_id = model_path_id_or_url path = Path(model_path_id_or_url) + + # fix relative paths + if path.exists() and not path.is_absolute(): + path = path.absolute() # make relative to current WD + # checkpoint file, or similar if path.is_file(): models_installed.update({str(path): self._install_path(path)}) From 21d5969942c2ed28cef2c9e47d1fb1d64fb49564 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Thu, 12 Oct 2023 22:35:02 -0400 Subject: [PATCH 2/2] strip leading and trailing quotes as well as whitespace --- invokeai/app/api/routers/models.py | 2 +- invokeai/backend/install/model_install_backend.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/invokeai/app/api/routers/models.py b/invokeai/app/api/routers/models.py index cb0832735b..a7b1f81252 100644 --- a/invokeai/app/api/routers/models.py +++ b/invokeai/app/api/routers/models.py @@ -152,7 +152,7 @@ async def import_model( ) -> ImportModelResponse: """Add a model using its local path, repo_id, or remote URL. Model characteristics will be probed and configured automatically""" - location = location.strip() + location = location.strip("\"' ") items_to_import = {location} prediction_types = {x.value: x for x in SchedulerPredictionType} logger = ApiDependencies.invoker.services.logger diff --git a/invokeai/backend/install/model_install_backend.py b/invokeai/backend/install/model_install_backend.py index bd26a7aa07..9224f5c8b2 100644 --- a/invokeai/backend/install/model_install_backend.py +++ b/invokeai/backend/install/model_install_backend.py @@ -236,7 +236,7 @@ class ModelInstall(object): if not models_installed: models_installed = dict() - model_path_id_or_url = str(model_path_id_or_url).strip() + model_path_id_or_url = str(model_path_id_or_url).strip("\"' ") # A little hack to allow nested routines to retrieve info on the requested ID self.current_id = model_path_id_or_url