Skip to content

Commit

Permalink
Merge pull request #14573 from continue-revolution/conrevo/add-p-to-cfg
Browse files Browse the repository at this point in the history
Add self to CFGDenoiserParams
  • Loading branch information
AUTOMATIC1111 authored Jan 8, 2024
2 parents 2f98a35 + 37906e4 commit 6869d95
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion modules/script_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, noise, x, xi):


class CFGDenoiserParams:
def __init__(self, x, image_cond, sigma, sampling_step, total_sampling_steps, text_cond, text_uncond):
def __init__(self, x, image_cond, sigma, sampling_step, total_sampling_steps, text_cond, text_uncond, denoiser=None):
self.x = x
"""Latent image representation in the process of being denoised"""

Expand All @@ -63,6 +63,9 @@ def __init__(self, x, image_cond, sigma, sampling_step, total_sampling_steps, te
self.text_uncond = text_uncond
""" Encoder hidden states of text conditioning from negative prompt"""

self.denoiser = denoiser
"""Current CFGDenoiser object with processing parameters"""


class CFGDenoisedParams:
def __init__(self, x, sampling_step, total_sampling_steps, inner_model):
Expand Down
2 changes: 1 addition & 1 deletion modules/sd_samplers_cfg_denoiser.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def apply_blend(current_latent):
sigma_in = torch.cat([torch.stack([sigma[i] for _ in range(n)]) for i, n in enumerate(repeats)] + [sigma] + [sigma])
image_cond_in = torch.cat([torch.stack([image_cond[i] for _ in range(n)]) for i, n in enumerate(repeats)] + [image_uncond] + [torch.zeros_like(self.init_latent)])

denoiser_params = CFGDenoiserParams(x_in, image_cond_in, sigma_in, state.sampling_step, state.sampling_steps, tensor, uncond)
denoiser_params = CFGDenoiserParams(x_in, image_cond_in, sigma_in, state.sampling_step, state.sampling_steps, tensor, uncond, self)
cfg_denoiser_callback(denoiser_params)
x_in = denoiser_params.x
image_cond_in = denoiser_params.image_cond
Expand Down

0 comments on commit 6869d95

Please sign in to comment.