Skip to content

Commit

Permalink
Update lora hotfix to new diffusers version(scale argument added)
Browse files Browse the repository at this point in the history
  • Loading branch information
StAlKeR7779 authored and hipsterusername committed Sep 15, 2023
1 parent 604fc00 commit ff3150a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions invokeai/backend/util/hotfixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,11 +772,13 @@ def forward(
# 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
Expand Down

0 comments on commit ff3150a

Please sign in to comment.