diff --git a/invokeai/backend/util/hotfixes.py b/invokeai/backend/util/hotfixes.py index 95f2c904ad8..32136452eba 100644 --- a/invokeai/backend/util/hotfixes.py +++ b/invokeai/backend/util/hotfixes.py @@ -5,7 +5,11 @@ from diffusers.configuration_utils import ConfigMixin, register_to_config from diffusers.loaders.single_file_model import FromOriginalModelMixin from diffusers.models.attention_processor import AttentionProcessor, AttnProcessor -from diffusers.models.controlnet import ControlNetConditioningEmbedding, ControlNetOutput, zero_module +from diffusers.models.controlnets.controlnet import ( + ControlNetConditioningEmbedding, + ControlNetOutput, + zero_module, +) from diffusers.models.embeddings import ( TextImageProjection, TextImageTimeEmbedding, @@ -775,7 +779,15 @@ def forward( diffusers.ControlNetModel = ControlNetModel -diffusers.models.controlnet.ControlNetModel = ControlNetModel +# Patch both the new and legacy module paths for compatibility +try: + diffusers.models.controlnets.controlnet.ControlNetModel = ControlNetModel +except Exception: + # Fallback for environments still exposing the legacy path + try: + diffusers.models.controlnet.ControlNetModel = ControlNetModel + except Exception: + pass # patch LoRACompatibleConv to use original Conv2D forward function