make self attention guidance idempotent

Follow up of d3365d6
This commit is contained in:
Cédric Deltheil 2023-10-11 10:42:21 +02:00 committed by Cédric Deltheil
parent 0024191c58
commit ac631bfb2e
2 changed files with 2 additions and 4 deletions

View file

@ -60,8 +60,7 @@ class StableDiffusion_1(LatentDiffusionModel):
if sag := self._find_sag_adapter(): if sag := self._find_sag_adapter():
sag.scale = scale sag.scale = scale
else: else:
sag = SD1SAGAdapter(target=self.unet, scale=scale) SD1SAGAdapter(target=self.unet, scale=scale).inject()
sag.inject()
else: else:
if sag := self._find_sag_adapter(): if sag := self._find_sag_adapter():
sag.eject() sag.eject()

View file

@ -101,8 +101,7 @@ class StableDiffusion_XL(LatentDiffusionModel):
if sag := self._find_sag_adapter(): if sag := self._find_sag_adapter():
sag.scale = scale sag.scale = scale
else: else:
sag = SDXLSAGAdapter(target=self.unet, scale=scale) SDXLSAGAdapter(target=self.unet, scale=scale).inject()
sag.inject()
else: else:
if sag := self._find_sag_adapter(): if sag := self._find_sag_adapter():
sag.eject() sag.eject()