@@ -147,6 +147,9 @@ class FluxDenoiseInvocation(BaseInvocation, WithMetadata, WithBoard):
147
147
description = FieldDescriptions .vae ,
148
148
input = Input .Connection ,
149
149
)
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.
150
153
151
154
ip_adapter : IPAdapterField | list [IPAdapterField ] | None = InputField (
152
155
description = FieldDescriptions .ip_adapter , title = "IP-Adapter" , default = None , input = Input .Connection
@@ -386,29 +389,26 @@ def _run_diffusion(
386
389
387
390
kontext_extension = None
388
391
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).
391
392
if not self .controlnet_vae :
392
393
raise ValueError ("A VAE (e.g., controlnet_vae) must be provided to use Kontext conditioning." )
393
394
394
395
kontext_extension = KontextExtension (
395
396
kontext_field = self .kontext_conditioning ,
396
397
context = context ,
397
- vae_field = self .controlnet_vae , # Pass the VAE field
398
+ vae_field = self .controlnet_vae ,
398
399
device = TorchDevice .choose_torch_device (),
399
400
dtype = inference_dtype ,
400
401
)
401
402
402
403
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 ]
404
405
if kontext_extension is not None :
405
406
final_img , final_img_ids = kontext_extension .apply (final_img , final_img_ids )
406
407
407
- # The denoise function will now use the combined tensors
408
408
x = denoise (
409
409
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 ,
412
412
pos_regional_prompting_extension = pos_regional_prompting_extension ,
413
413
neg_regional_prompting_extension = neg_regional_prompting_extension ,
414
414
timesteps = timesteps ,
0 commit comments