Skip to content

Commit 9066dc1

Browse files
tidy(nodes): remove extraneous comments & add useful ones
1 parent 075345b commit 9066dc1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

invokeai/app/invocations/flux_denoise.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ class FluxDenoiseInvocation(BaseInvocation, WithMetadata, WithBoard):
147147
description=FieldDescriptions.vae,
148148
input=Input.Connection,
149149
)
150+
# This node accepts a images for features like FLUX Fill, ControlNet, and Kontext, but needs to operate on them in
151+
# latent space. We'll run the VAE to encode them in this node instead of requiring the user to run the VAE in
152+
# upstream nodes.
150153

151154
ip_adapter: IPAdapterField | list[IPAdapterField] | None = InputField(
152155
description=FieldDescriptions.ip_adapter, title="IP-Adapter", default=None, input=Input.Connection
@@ -386,29 +389,26 @@ def _run_diffusion(
386389

387390
kontext_extension = None
388391
if self.kontext_conditioning is not None:
389-
# We need a VAE to encode the reference image. We can reuse the
390-
# controlnet_vae field as it serves a similar purpose (image to latents).
391392
if not self.controlnet_vae:
392393
raise ValueError("A VAE (e.g., controlnet_vae) must be provided to use Kontext conditioning.")
393394

394395
kontext_extension = KontextExtension(
395396
kontext_field=self.kontext_conditioning,
396397
context=context,
397-
vae_field=self.controlnet_vae, # Pass the VAE field
398+
vae_field=self.controlnet_vae,
398399
device=TorchDevice.choose_torch_device(),
399400
dtype=inference_dtype,
400401
)
401402

402403
final_img, final_img_ids = x, img_ids
403-
original_seq_len = x.shape[1] # Store the original sequence length
404+
original_seq_len = x.shape[1]
404405
if kontext_extension is not None:
405406
final_img, final_img_ids = kontext_extension.apply(final_img, final_img_ids)
406407

407-
# The denoise function will now use the combined tensors
408408
x = denoise(
409409
model=transformer,
410-
img=final_img, # Pass the combined image tokens
411-
img_ids=final_img_ids, # Pass the combined image IDs
410+
img=final_img,
411+
img_ids=final_img_ids,
412412
pos_regional_prompting_extension=pos_regional_prompting_extension,
413413
neg_regional_prompting_extension=neg_regional_prompting_extension,
414414
timesteps=timesteps,

0 commit comments

Comments
 (0)