From 0c724e67707e64973c2bfd5a070e6ff1a10f3d52 Mon Sep 17 00:00:00 2001 From: Ricardo-M-L Date: Wed, 8 Apr 2026 23:05:01 +0800 Subject: [PATCH] fix: correct attribute error in TangentialCFG and undefined variable in FrequencyDecoupledGuidance Fix two bugs in the guiders module: 1. TangentialClassifierFreeGuidance.is_conditional references `self._num_outputs_prepared` which does not exist. All other guiders use `self._count_prepared` (defined in BaseGuidance). This causes an AttributeError whenever is_conditional is accessed. 2. FrequencyDecoupledGuidance.forward uses `pred_cond_freq` in the else branch (line 278) where FDG is disabled for a level, but that variable is only defined inside the if branch. If the first pyramid level has FDG disabled, this raises a NameError. Even when a prior level defined it, the wrong level's data would be used. Fixed to use `pred_cond_pyramid[level]` which correctly indexes the pyramid. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/diffusers/guiders/frequency_decoupled_guidance.py | 2 +- src/diffusers/guiders/tangential_classifier_free_guidance.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffusers/guiders/frequency_decoupled_guidance.py b/src/diffusers/guiders/frequency_decoupled_guidance.py index b92ddf2c03f9..917d67a3d5b5 100644 --- a/src/diffusers/guiders/frequency_decoupled_guidance.py +++ b/src/diffusers/guiders/frequency_decoupled_guidance.py @@ -275,7 +275,7 @@ def forward(self, pred_cond: torch.Tensor, pred_uncond: torch.Tensor | None = No pred_guided_pyramid.append(pred) else: # Add the current pred_cond_pyramid level as the "non-FDG" prediction - pred_guided_pyramid.append(pred_cond_freq) + pred_guided_pyramid.append(pred_cond_pyramid[level]) # Convert from frequency space back to data (e.g. pixel) space by applying inverse freq transform pred = build_image_from_pyramid(pred_guided_pyramid) diff --git a/src/diffusers/guiders/tangential_classifier_free_guidance.py b/src/diffusers/guiders/tangential_classifier_free_guidance.py index c8911f4a69d9..2c885e28a202 100644 --- a/src/diffusers/guiders/tangential_classifier_free_guidance.py +++ b/src/diffusers/guiders/tangential_classifier_free_guidance.py @@ -101,7 +101,7 @@ def forward(self, pred_cond: torch.Tensor, pred_uncond: torch.Tensor | None = No @property def is_conditional(self) -> bool: - return self._num_outputs_prepared == 1 + return self._count_prepared == 1 @property def num_conditions(self) -> int: