From 6d261a5a13c782712b979b693f3aeddefe94dfc9 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Fri, 29 Mar 2024 22:32:43 +1100 Subject: [PATCH] fix(mm): handle relative conversion config paths I have tested main, controlnet and vae checkpoint conversions. --- invokeai/app/services/model_install/model_install_default.py | 2 +- invokeai/backend/model_manager/load/model_loaders/controlnet.py | 2 +- .../model_manager/load/model_loaders/stable_diffusion.py | 2 +- invokeai/backend/model_manager/load/model_loaders/vae.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/invokeai/app/services/model_install/model_install_default.py b/invokeai/app/services/model_install/model_install_default.py index abf74daa5a..2951d2ba43 100644 --- a/invokeai/app/services/model_install/model_install_default.py +++ b/invokeai/app/services/model_install/model_install_default.py @@ -612,7 +612,7 @@ class ModelInstallService(ModelInstallServiceBase): if isinstance(info, CheckpointConfigBase): # Checkpoints have a config file needed for conversion. Same handling as the model weights - if it's in the # invoke-managed legacy config dir, we use a relative path. - legacy_config_path = Path(info.config_path).resolve() + legacy_config_path = self.app_config.legacy_conf_path / info.config_path if legacy_config_path.is_relative_to(self.app_config.legacy_conf_path): legacy_config_path = legacy_config_path.relative_to(self.app_config.legacy_conf_path) info.config_path = legacy_config_path.as_posix() diff --git a/invokeai/backend/model_manager/load/model_loaders/controlnet.py b/invokeai/backend/model_manager/load/model_loaders/controlnet.py index 861ba700cc..b782b867fd 100644 --- a/invokeai/backend/model_manager/load/model_loaders/controlnet.py +++ b/invokeai/backend/model_manager/load/model_loaders/controlnet.py @@ -44,7 +44,7 @@ class ControlNetLoader(GenericDiffusersLoader): ) self._logger.info(f"Converting {model_path} to diffusers format") - with open(self._app_config.root_path / config.config_path, "r") as config_stream: + with open(self._app_config.legacy_conf_path / config.config_path, "r") as config_stream: convert_controlnet_to_diffusers( model_path, output_path, diff --git a/invokeai/backend/model_manager/load/model_loaders/stable_diffusion.py b/invokeai/backend/model_manager/load/model_loaders/stable_diffusion.py index c3260957c8..3ed0fd7361 100644 --- a/invokeai/backend/model_manager/load/model_loaders/stable_diffusion.py +++ b/invokeai/backend/model_manager/load/model_loaders/stable_diffusion.py @@ -98,7 +98,7 @@ class StableDiffusionDiffusersModel(GenericDiffusersLoader): model_path, output_path, model_type=self.model_base_to_model_type[base], - original_config_file=self._app_config.root_path / config.config_path, + original_config_file=self._app_config.legacy_conf_path / config.config_path, extract_ema=True, from_safetensors=model_path.suffix == ".safetensors", precision=self._torch_dtype, diff --git a/invokeai/backend/model_manager/load/model_loaders/vae.py b/invokeai/backend/model_manager/load/model_loaders/vae.py index 7669ff0e19..df15f3ebfe 100644 --- a/invokeai/backend/model_manager/load/model_loaders/vae.py +++ b/invokeai/backend/model_manager/load/model_loaders/vae.py @@ -44,7 +44,7 @@ class VAELoader(GenericDiffusersLoader): raise Exception(f"VAE conversion not supported for model type: {config.base}") else: assert isinstance(config, CheckpointConfigBase) - config_file = self._app_config.root_path / config.config_path + config_file = self._app_config.legacy_conf_path / config.config_path if model_path.suffix == ".safetensors": checkpoint = safetensors_load_file(model_path, device="cpu")