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 WanFirstLastFrameToVideo node to use the new model.
comfyanonymouseba7a25e7abf
diff --git a/comfy_extras/nodes_wan.py b/comfy_extras/nodes_wan.pyindex 2d0f31ac8..8ad358ce8 100644--- a/comfy_extras/nodes_wan.py+++ b/comfy_extras/nodes_wan.py@@ -4,6 +4,7 @@ import torchimport comfy.model_managementimport comfy.utilsimport comfy.latent_formats+import comfy.clip_visionclass WanImageToVideo:@@ -99,7 +100,7 @@ class WanFunControlToVideo:out_latent["samples"] = latentreturn (positive, negative, out_latent)-class WanFunInpaintToVideo:+class WanFirstLastFrameToVideo:@classmethoddef INPUT_TYPES(s):return {"required": {"positive": ("CONDITIONING", ),@@ -110,7 +111,8 @@ class WanFunInpaintToVideo:"length": ("INT", {"default": 81, "min": 1, "max": nodes.MAX_RESOLUTION, "step": 4}),"batch_size": ("INT", {"default": 1, "min": 1, "max": 4096}),},- "optional": {"clip_vision_output": ("CLIP_VISION_OUTPUT", ),+ "optional": {"clip_vision_start_image": ("CLIP_VISION_OUTPUT", ),+ "clip_vision_end_image": ("CLIP_VISION_OUTPUT", ),"start_image": ("IMAGE", ),"end_image": ("IMAGE", ),}}@@ -121,7 +123,7 @@ class WanFunInpaintToVideo:CATEGORY = "conditioning/video_models"- def encode(self, positive, negative, vae, width, height, length, batch_size, start_image=None, end_image=None, clip_vision_output=None):+ def encode(self, positive, negative, vae, width, height, length, batch_size, start_image=None, end_image=None, clip_vision_start_image=None, clip_vision_end_image=None):latent = torch.zeros([batch_size, 16, ((length - 1) // 4) + 1, height // 8, width // 8], device=comfy.model_management.intermediate_device())if start_image is not None:start_image = comfy.utils.common_upscale(start_image[:length].movedim(-1, 1), width, height, "bilinear", "center").movedim(1, -1)@@ -144,6 +146,17 @@ class WanFunInpaintToVideo:positive = node_helpers.conditioning_set_values(positive, {"concat_latent_image": concat_latent_image, "concat_mask": mask})negative = node_helpers.conditioning_set_values(negative, {"concat_latent_image": concat_latent_image, "concat_mask": mask})+ if clip_vision_start_image is not None:+ clip_vision_output = clip_vision_start_image++ if clip_vision_end_image is not None:+ if clip_vision_output is not None:+ states = torch.cat([clip_vision_output.penultimate_hidden_states, clip_vision_end_image.penultimate_hidden_states], dim=-2)+ clip_vision_output = comfy.clip_vision.Output()+ clip_vision_output.penultimate_hidden_states = states+ else:+ clip_vision_output = clip_vision_end_image+if clip_vision_output is not None:positive = node_helpers.conditioning_set_values(positive, {"clip_vision_output": clip_vision_output})negative = node_helpers.conditioning_set_values(negative, {"clip_vision_output": clip_vision_output})@@ -152,8 +165,37 @@ class WanFunInpaintToVideo:out_latent["samples"] = latentreturn (positive, negative, out_latent)++class WanFunInpaintToVideo:+ @classmethod+ def INPUT_TYPES(s):+ return {"required": {"positive": ("CONDITIONING", ),+ "negative": ("CONDITIONING", ),+ "vae": ("VAE", ),+ "width": ("INT", {"default": 832, "min": 16, "max": nodes.MAX_RESOLUTION, "step": 16}),+ "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}),+ },+ "optional": {"clip_vision_output": ("CLIP_VISION_OUTPUT", ),+ "start_image": ("IMAGE", ),+ "end_image": ("IMAGE", ),+ }}++ RETURN_TYPES = ("CONDITIONING", "CONDITIONING", "LATENT")+ RETURN_NAMES = ("positive", "negative", "latent")+ FUNCTION = "encode"++ CATEGORY = "conditioning/video_models"++ def encode(self, positive, negative, vae, width, height, length, batch_size, start_image=None, end_image=None, clip_vision_output=None):+ flfv = WanFirstLastFrameToVideo()+ return flfv.encode(positive, negative, vae, width, height, length, batch_size, start_image=start_image, end_image=end_image, clip_vision_start_image=clip_vision_output)++NODE_CLASS_MAPPINGS = {"WanImageToVideo": WanImageToVideo,"WanFunControlToVideo": WanFunControlToVideo,"WanFunInpaintToVideo": WanFunInpaintToVideo,+ "WanFirstLastFrameToVideo": WanFirstLastFrameToVideo,}