From 4e836444336a9ddd690689e9dbbff3e09b77fd5a Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Tue, 5 Sep 2023 08:18:51 -0400 Subject: [PATCH] if sdxl-vae-fp16-fix model is available then bake it in when converting ckpts --- invokeai/backend/model_management/models/sdxl.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/invokeai/backend/model_management/models/sdxl.py b/invokeai/backend/model_management/models/sdxl.py index 41586e35b9..43448bbacb 100644 --- a/invokeai/backend/model_management/models/sdxl.py +++ b/invokeai/backend/model_management/models/sdxl.py @@ -119,11 +119,22 @@ class StableDiffusionXLModel(DiffusersModel): if isinstance(config, cls.CheckpointConfig): from invokeai.backend.model_management.models.stable_diffusion import _convert_ckpt_and_cache + # Hack in VAE-fp16 fix - If model sdxl-vae-fp16-fix is installed, + # then we bake it into the converted model. + from invokeai.app.services.config import InvokeAIAppConfig + + kwargs = dict() + app_config = InvokeAIAppConfig.get_config() + vae_path = app_config.models_path / 'sdxl/vae/sdxl-vae-fp16-fix' + if vae_path.exists(): + kwargs['vae_path'] = vae_path + return _convert_ckpt_and_cache( version=base_model, model_config=config, output_path=output_path, use_safetensors=False, # corrupts sdxl models for some reason + **kwargs, ) else: return model_path