From 7a415f47a90915d755767c29e9f5bcc157fedefe Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Sun, 22 Sep 2024 01:24:52 -0400 Subject: [PATCH] Add an optional VAE input to the ControlNetApplyAdvanced node. Deprecate the other controlnet nodes. --- comfy/controlnet.py | 2 +- comfy_extras/nodes_sd3.py | 3 ++- nodes.py | 8 ++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/comfy/controlnet.py b/comfy/controlnet.py index 9dfd6997..37914e5f 100644 --- a/comfy/controlnet.py +++ b/comfy/controlnet.py @@ -226,7 +226,7 @@ class ControlNet(ControlBase): compression_ratio *= self.vae.downscale_ratio else: if self.latent_format is not None: - raise ValueError("This Controlnet needs a VAE but none was provided, please use a different ControlNetApply node with a VAE input.") + raise ValueError("This Controlnet needs a VAE but none was provided, please use a ControlNetApply node with a VAE input and connect it.") self.cond_hint = comfy.utils.common_upscale(self.cond_hint_original, x_noisy.shape[3] * compression_ratio, x_noisy.shape[2] * compression_ratio, self.upscale_algorithm, "center") if self.vae is not None: loaded_models = comfy.model_management.loaded_models(only_currently_used=True) diff --git a/comfy_extras/nodes_sd3.py b/comfy_extras/nodes_sd3.py index 60a85bbd..ddf538de 100644 --- a/comfy_extras/nodes_sd3.py +++ b/comfy_extras/nodes_sd3.py @@ -93,6 +93,7 @@ class ControlNetApplySD3(nodes.ControlNetApplyAdvanced): "end_percent": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.001}) }} CATEGORY = "conditioning/controlnet" + DEPRECATED = True NODE_CLASS_MAPPINGS = { "TripleCLIPLoader": TripleCLIPLoader, @@ -103,5 +104,5 @@ NODE_CLASS_MAPPINGS = { NODE_DISPLAY_NAME_MAPPINGS = { # Sampling - "ControlNetApplySD3": "Apply Controlnet", + "ControlNetApplySD3": "Apply Controlnet with VAE", } diff --git a/nodes.py b/nodes.py index c4595f6a..a4065c76 100644 --- a/nodes.py +++ b/nodes.py @@ -787,6 +787,7 @@ class ControlNetApply: RETURN_TYPES = ("CONDITIONING",) FUNCTION = "apply_controlnet" + DEPRECATED = True CATEGORY = "conditioning/controlnet" def apply_controlnet(self, conditioning, control_net, image, strength): @@ -816,7 +817,10 @@ class ControlNetApplyAdvanced: "strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}), "start_percent": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.001}), "end_percent": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.001}) - }} + }, + "optional": {"vae": ("VAE", ), + } + } RETURN_TYPES = ("CONDITIONING","CONDITIONING") RETURN_NAMES = ("positive", "negative") @@ -1918,7 +1922,7 @@ NODE_DISPLAY_NAME_MAPPINGS = { "ConditioningSetAreaPercentage": "Conditioning (Set Area with Percentage)", "ConditioningSetMask": "Conditioning (Set Mask)", "ControlNetApply": "Apply ControlNet (OLD)", - "ControlNetApplyAdvanced": "Apply ControlNet (OLD Advanced)", + "ControlNetApplyAdvanced": "Apply ControlNet", # Latent "VAEEncodeForInpaint": "VAE Encode (for Inpainting)", "SetLatentNoiseMask": "Set Latent Noise Mask",