The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Add strength control for vace. (#7717)
comfyanonymous5d0d4ee98a24
diff --git a/comfy/ldm/wan/model.py b/comfy/ldm/wan/model.pyindex 5e7848bd5..4ef86d5f2 100644--- a/comfy/ldm/wan/model.py+++ b/comfy/ldm/wan/model.py@@ -582,6 +582,7 @@ class VaceWanModel(WanModel):t,context,vace_context,+ vace_strength=1.0,clip_fea=None,freqs=None,transformer_options={},@@ -629,7 +630,7 @@ class VaceWanModel(WanModel):ii = self.vace_layers_mapping.get(i, None)if ii is not None:c_skip, c = self.vace_blocks[ii](c, x=x_orig, e=e0, freqs=freqs, context=context, context_img_len=context_img_len)- x += c_skip+ x += c_skip * vace_strength# headx = self.head(x, e)diff --git a/comfy/model_base.py b/comfy/model_base.pyindex 04a101526..b0c6a465b 100644--- a/comfy/model_base.py+++ b/comfy/model_base.py@@ -1068,6 +1068,9 @@ class WAN21_Vace(WAN21):mask = torch.ones(noise_shape, device=noise.device, dtype=noise.dtype)out['vace_context'] = comfy.conds.CONDRegular(torch.cat([vace_frames.to(noise), mask.to(noise)], dim=1))++ vace_strength = kwargs.get("vace_strength", 1.0)+ out['vace_strength'] = comfy.conds.CONDConstant(vace_strength)return outdiff --git a/comfy_extras/nodes_wan.py b/comfy_extras/nodes_wan.pyindex 19a6cdfa4..9dda64597 100644--- a/comfy_extras/nodes_wan.py+++ b/comfy_extras/nodes_wan.py@@ -203,6 +203,7 @@ class WanVaceToVideo:"height": ("INT", {"default": 480, "min": 16, "max": nodes.MAX_RESOLUTION, "step": 16}),"length": ("INT", {"default": 81, "min": 1, "max": nodes.MAX_RESOLUTION, "step": 4}),"batch_size": ("INT", {"default": 1, "min": 1, "max": 4096}),+ "strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1000.0, "step": 0.01}),},"optional": {"control_video": ("IMAGE", ),"control_masks": ("MASK", ),@@ -217,7 +218,7 @@ class WanVaceToVideo:EXPERIMENTAL = True- def encode(self, positive, negative, vae, width, height, length, batch_size, control_video=None, control_masks=None, reference_image=None):+ def encode(self, positive, negative, vae, width, height, length, batch_size, strength, control_video=None, control_masks=None, reference_image=None):latent_length = ((length - 1) // 4) + 1if control_video is not None:control_video = comfy.utils.common_upscale(control_video[:length].movedim(-1, 1), width, height, "bilinear", "center").movedim(1, -1)@@ -267,8 +268,8 @@ class WanVaceToVideo:trim_latent = reference_image.shape[2]mask = mask.unsqueeze(0)- positive = node_helpers.conditioning_set_values(positive, {"vace_frames": control_video_latent, "vace_mask": mask})- negative = node_helpers.conditioning_set_values(negative, {"vace_frames": control_video_latent, "vace_mask": mask})+ positive = node_helpers.conditioning_set_values(positive, {"vace_frames": control_video_latent, "vace_mask": mask, "vace_strength": strength})+ negative = node_helpers.conditioning_set_values(negative, {"vace_frames": control_video_latent, "vace_mask": mask, "vace_strength": strength})latent = torch.zeros([batch_size, 16, latent_length, height // 8, width // 8], device=comfy.model_management.intermediate_device())out_latent = {}