diff --git a/adv_control/nodes_main.py b/adv_control/nodes_main.py index a5bc2aa..e8aaee0 100644 --- a/adv_control/nodes_main.py +++ b/adv_control/nodes_main.py @@ -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 = [] diff --git a/tests/test_modern_control.py b/tests/test_modern_control.py index 330f42b..c566f6c 100644 --- a/tests/test_modern_control.py +++ b/tests/test_modern_control.py @@ -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))