From ff3150a818245c6dc83ba742045f18d5242a7c0d Mon Sep 17 00:00:00 2001 From: Sergey Borisov Date: Wed, 13 Sep 2023 21:37:08 +0300 Subject: [PATCH] Update lora hotfix to new diffusers version(scale argument added) --- invokeai/backend/util/hotfixes.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/invokeai/backend/util/hotfixes.py b/invokeai/backend/util/hotfixes.py index 983d0b7601..852d640161 100644 --- a/invokeai/backend/util/hotfixes.py +++ b/invokeai/backend/util/hotfixes.py @@ -772,11 +772,13 @@ diffusers.models.controlnet.ControlNetModel = ControlNetModel # NOTE: with this patch, torch.compile crashes on 2.0 torch(already fixed in nightly) # https://github.com/huggingface/diffusers/pull/4315 # https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/lora.py#L96C18-L96C18 -def new_LoRACompatibleConv_forward(self, x): +def new_LoRACompatibleConv_forward(self, hidden_states, scale: float = 1.0): if self.lora_layer is None: - return super(diffusers.models.lora.LoRACompatibleConv, self).forward(x) + return super(diffusers.models.lora.LoRACompatibleConv, self).forward(hidden_states) else: - return super(diffusers.models.lora.LoRACompatibleConv, self).forward(x) + self.lora_layer(x) + return super(diffusers.models.lora.LoRACompatibleConv, self).forward(hidden_states) + ( + scale * self.lora_layer(hidden_states) + ) diffusers.models.lora.LoRACompatibleConv.forward = new_LoRACompatibleConv_forward