Skip to content

Commit

Permalink
Re-do NGMS Logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Panchovix committed Jul 12, 2024
1 parent 6943983 commit 7e1aa11
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions modules/sd_samplers_cfg_denoiser.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,17 +306,22 @@ def forward(self, x, sigma, uncond, cond, cond_scale, s_min_uncond, image_cond):
# Initialize skip_uncond
skip_uncond = False

# Implement skip_uncond logic
if self.step < shared.opts.skip_early_cond:
skip_uncond = True
elif shared.opts.skip_early_cond != 0. and self.step / self.total_steps <= shared.opts.skip_early_cond:
skip_uncond = True
self.p.extra_generation_params["Skip Early CFG"] = shared.opts.skip_early_cond
elif (self.step % 2 or shared.opts.s_min_uncond_all) and s_min_uncond > 0 and sigma[0] < s_min_uncond and not is_edit_model:
skip_uncond = True
self.p.extra_generation_params["NGMS"] = s_min_uncond
if shared.opts.s_min_uncond_all:
self.p.extra_generation_params["NGMS all steps"] = shared.opts.s_min_uncond_all
# NGMS logic
if s_min_uncond > 0 and sigma[0] < s_min_uncond and not is_edit_model:
if self.step % 2 == 0 or shared.opts.s_min_uncond_all:
skip_uncond = True
self.p.extra_generation_params["NGMS"] = s_min_uncond
if shared.opts.s_min_uncond_all:
self.p.extra_generation_params["NGMS all steps"] = shared.opts.s_min_uncond_all
print(f"Applying NGMS at step {self.step}: s_min_uncond = {s_min_uncond}, sigma = {sigma[0]}")

# Existing skip_early_cond logic
if not skip_uncond:
if self.step < shared.opts.skip_early_cond:
skip_uncond = True
elif shared.opts.skip_early_cond != 0. and self.step / self.total_steps <= shared.opts.skip_early_cond:
skip_uncond = True
self.p.extra_generation_params["Skip Early CFG"] = shared.opts.skip_early_cond

# Implement padding logic
self.padded_cond_uncond = False
Expand Down

0 comments on commit 7e1aa11

Please sign in to comment.