Skip to content

Commit 21a05f4

Browse files
fix controlnets for latest diffusers v
1 parent efcb1be commit 21a05f4

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

invokeai/backend/util/hotfixes.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
from diffusers.configuration_utils import ConfigMixin, register_to_config
66
from diffusers.loaders.single_file_model import FromOriginalModelMixin
77
from diffusers.models.attention_processor import AttentionProcessor, AttnProcessor
8-
from diffusers.models.controlnet import ControlNetConditioningEmbedding, ControlNetOutput, zero_module
8+
from diffusers.models.controlnets.controlnet import (
9+
ControlNetConditioningEmbedding,
10+
ControlNetOutput,
11+
zero_module,
12+
)
913
from diffusers.models.embeddings import (
1014
TextImageProjection,
1115
TextImageTimeEmbedding,
@@ -775,7 +779,15 @@ def forward(
775779

776780

777781
diffusers.ControlNetModel = ControlNetModel
778-
diffusers.models.controlnet.ControlNetModel = ControlNetModel
782+
# Patch both the new and legacy module paths for compatibility
783+
try:
784+
diffusers.models.controlnets.controlnet.ControlNetModel = ControlNetModel
785+
except Exception:
786+
# Fallback for environments still exposing the legacy path
787+
try:
788+
diffusers.models.controlnet.ControlNetModel = ControlNetModel
789+
except Exception:
790+
pass
779791

780792

781793
# patch LoRACompatibleConv to use original Conv2D forward function

0 commit comments

Comments
 (0)