diff --git a/invokeai/backend/install/model_install_backend.py b/invokeai/backend/install/model_install_backend.py index f0dcb7585b..7a9acd4235 100644 --- a/invokeai/backend/install/model_install_backend.py +++ b/invokeai/backend/install/model_install_backend.py @@ -152,10 +152,9 @@ class ModelInstall(object): path = model_info.get("path") if not path: return False - for autodir in ['autoimport_dir','lora_dir','embedding_dir','controlnet_dir']: + for autodir in ["autoimport_dir", "lora_dir", "embedding_dir", "controlnet_dir"]: if autodir_path := getattr(self.config, autodir): autodir_path = self.config.root_path / autodir_path - print(f'{path} => {autodir_path}; is_relative={Path(path).is_relative_to(autodir_path)}',file=log) if Path(path).is_relative_to(autodir_path): return True return False diff --git a/invokeai/backend/model_management/model_manager.py b/invokeai/backend/model_management/model_manager.py index a23902c407..81dc0e5d07 100644 --- a/invokeai/backend/model_management/model_manager.py +++ b/invokeai/backend/model_management/model_manager.py @@ -723,13 +723,11 @@ class ModelManager(object): # if this is a model file/directory that we manage ourselves, we need to move it if old_path.is_relative_to(self.app_config.models_path): - new_path = ( - self.resolve_model_path( - Path( - BaseModelType(new_base).value, - ModelType(model_type).value, - new_name, - ) + new_path = self.resolve_model_path( + Path( + BaseModelType(new_base).value, + ModelType(model_type).value, + new_name, ) ) move(old_path, new_path) @@ -811,7 +809,7 @@ class ModelManager(object): return result - def resolve_model_path(self, path: Union[Path,str]) -> Path: + def resolve_model_path(self, path: Union[Path, str]) -> Path: """return relative paths based on configured models_path""" return self.app_config.models_path / path @@ -935,7 +933,7 @@ class ModelManager(object): try: if model_key in self.models: raise DuplicateModelException(f"Model with key {model_key} added twice") - + model_path = self.relative_model_path(model_path) model_config: ModelConfigBase = model_class.probe_config(str(model_path)) self.models[model_key] = model_config diff --git a/invokeai/frontend/install/model_install.py b/invokeai/frontend/install/model_install.py index 97065bf2d8..4272e05207 100644 --- a/invokeai/frontend/install/model_install.py +++ b/invokeai/frontend/install/model_install.py @@ -650,6 +650,7 @@ def process_and_execute( conn_out.send_bytes("*done*".encode("utf-8")) conn_out.close() + # -------------------------------------------------------- def select_and_download_models(opt: Namespace): precision = "float32" if opt.full_precision else choose_precision(torch.device(choose_torch_device()))