Skip to content

Commit 8fc0ce7

Browse files
authored
Fix wrong conditioning used (#3595)
As it said in comment to this branch we want to use conditioning run: ```python if cfg_injection: # only applying ControlNet to conditional instead of in unconditioned ``` But in code used unconditioning embeddings(`conditioning_data.unconditioned_embeddings`). Later in code confirms that we want to run conditioning generation by comment and tensor concatenation order(as all code expect to get [uc, c] tensor): ```python if cfg_injection: # Inferred ControlNet only for the conditional batch. # To apply the output of ControlNet to both the unconditional and conditional batches, # add 0 to the unconditional batch to keep it unchanged. down_samples = [torch.cat([torch.zeros_like(d), d]) for d in down_samples] mid_sample = torch.cat([torch.zeros_like(mid_sample), mid_sample]) ```
2 parents d4ec887 + 9348dc8 commit 8fc0ce7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

invokeai/backend/stable_diffusion/diffusers_pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ def step(
631631
control_latent_input = torch.cat([unet_latent_input] * 2)
632632

633633
if cfg_injection: # only applying ControlNet to conditional instead of in unconditioned
634-
encoder_hidden_states = torch.cat([conditioning_data.unconditioned_embeddings])
634+
encoder_hidden_states = conditioning_data.text_embeddings
635635
else:
636636
encoder_hidden_states = torch.cat([conditioning_data.unconditioned_embeddings,
637637
conditioning_data.text_embeddings])

0 commit comments

Comments
 (0)