Commit 293f44e6 authored by MrCheeze's avatar MrCheeze

Fix bug where is_using_v_parameterization_for_sd2 fails because the sd_hijack...

Fix bug where is_using_v_parameterization_for_sd2 fails because the sd_hijack is only partially undone
parent f0f100e6
...@@ -38,9 +38,6 @@ ldm.models.diffusion.ddpm.print = shared.ldm_print ...@@ -38,9 +38,6 @@ ldm.models.diffusion.ddpm.print = shared.ldm_print
optimizers = [] optimizers = []
current_optimizer: sd_hijack_optimizations.SdOptimization = None 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(): def list_optimizers():
new_optimizers = script_callbacks.list_optimizers_callback() new_optimizers = script_callbacks.list_optimizers_callback()
...@@ -258,6 +255,9 @@ class StableDiffusionModelHijack: ...@@ -258,6 +255,9 @@ class StableDiffusionModelHijack:
import modules.models.diffusion.ddpm_edit 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): if isinstance(m, ldm.models.diffusion.ddpm.LatentDiffusion):
sd_unet.original_forward = ldm_original_forward sd_unet.original_forward = ldm_original_forward
elif isinstance(m, modules.models.diffusion.ddpm_edit.LatentDiffusion): elif isinstance(m, modules.models.diffusion.ddpm_edit.LatentDiffusion):
...@@ -303,6 +303,9 @@ class StableDiffusionModelHijack: ...@@ -303,6 +303,9 @@ class StableDiffusionModelHijack:
self.layers = None self.layers = None
self.clip = 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 sd_unet.original_forward = None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment