Skip controls with zero effect masks

This commit is contained in:
Jedrzej Kosinski
2026-07-17 23:48:35 -07:00
parent 42cdfe6c88
commit b5764c344f
2 changed files with 21 additions and 1 deletions
+1 -1
View File
@@ -114,7 +114,7 @@ class AdvancedControlNetApply(io.ComfyNode):
mask_optional: Tensor=None, vae_optional=None,
timestep_kf: TimestepKeyframeGroup=None, latent_kf_override: LatentKeyframeGroup=None,
weights_override: ControlWeights=None, control_apply_to_uncond=False, extra_concat=None):
if strength == 0:
if strength == 0 or (mask_optional is not None and mask_optional.count_nonzero().item() == 0):
return io.NodeOutput(positive, negative)
if extra_concat is None:
extra_concat = []
+20
View File
@@ -156,6 +156,26 @@ class T2IAdapterTests(unittest.TestCase):
self.assertIs(control.cond_hint_original, original_hint)
class AdvancedControlNetApplyTests(unittest.TestCase):
def test_all_zero_effect_mask_returns_original_conditioning(self):
positive = [[sentinel.positive_tensor, {"name": "positive"}]]
negative = [[sentinel.negative_tensor, {"name": "negative"}]]
result = AdvancedControlNetApply.execute(
positive=positive,
negative=negative,
control_net=sentinel.control_net,
image=torch.ones((1, 8, 8, 3)),
strength=1.0,
start_percent=0.0,
end_percent=1.0,
mask_optional=torch.zeros((1, 8, 8)),
)
self.assertIs(result.args[0], positive)
self.assertIs(result.args[1], negative)
class AdvancedInpaintingApplyTests(unittest.TestCase):
def test_source_mask_and_effect_mask_stay_independent(self):
image = torch.ones((1, 2, 2, 3))