Skip to content

Commit

Permalink
potential fix for #14172
Browse files Browse the repository at this point in the history
  • Loading branch information
AUTOMATIC1111 committed Dec 2, 2023
1 parent 11d23e8 commit a5f61aa
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions modules/sd_hijack.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
optimizers = []
current_optimizer: sd_hijack_optimizations.SdOptimization = None

ldm_original_forward = patches.patch(__file__, ldm.modules.diffusionmodules.openaimodel.UNetModel, "forward", sd_unet.UNetModel_forward)
sgm_original_forward = patches.patch(__file__, sgm.modules.diffusionmodules.openaimodel.UNetModel, "forward", sd_unet.UNetModel_forward)


def list_optimizers():
new_optimizers = script_callbacks.list_optimizers_callback()

Expand Down Expand Up @@ -255,9 +259,6 @@ def flatten(el):

import modules.models.diffusion.ddpm_edit

ldm_original_forward = patches.patch(__file__, ldm.modules.diffusionmodules.openaimodel.UNetModel, "forward", sd_unet.UNetModel_forward)
sgm_original_forward = patches.patch(__file__, sgm.modules.diffusionmodules.openaimodel.UNetModel, "forward", sd_unet.UNetModel_forward)

if isinstance(m, ldm.models.diffusion.ddpm.LatentDiffusion):
sd_unet.original_forward = ldm_original_forward
elif isinstance(m, modules.models.diffusion.ddpm_edit.LatentDiffusion):
Expand Down Expand Up @@ -303,11 +304,6 @@ def undo_hijack(self, m):
self.layers = None
self.clip = None

patches.undo(__file__, ldm.modules.diffusionmodules.openaimodel.UNetModel, "forward")
patches.undo(__file__, sgm.modules.diffusionmodules.openaimodel.UNetModel, "forward")

sd_unet.original_forward = None


def apply_circular(self, enable):
if self.circular_enabled == enable:
Expand Down

0 comments on commit a5f61aa

Please sign in to comment.