From 0e4b11f628f7bbdf4335514474ac7f7959010b80 Mon Sep 17 00:00:00 2001 From: Flow-two Date: Thu, 27 Mar 2025 02:29:14 +0900 Subject: [PATCH] added node GetImagesFromBatchRanged --- __init__.py | 6 ++++-- nodes/nodes.py | 27 +++++++++++++++++++++++++-- pyproject.toml | 2 +- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/__init__.py b/__init__.py index aaec59b..49fc799 100644 --- a/__init__.py +++ b/__init__.py @@ -5,9 +5,11 @@ __all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"] WEB_DIRECTORY = "./web" NODE_CLASS_MAPPINGS = { - "WanImageToVideo_F2": WanImageToVideo_F2, + "WanImageToVideo_F2": WanImageToVideo_F2, + "GetImagesFromBatchRanged_F2": GetImagesFromBatchRanged_F2 } NODE_DISPLAY_NAME_MAPPINGS = { - "WanImageToVideo_F2": "WanImageToVideo (Flow2)", + "WanImageToVideo_F2": "WanImageToVideo (Flow2)", + "GetImagesFromBatchRanged_F2": "Get Images From Batch Ranged" } \ No newline at end of file diff --git a/nodes/nodes.py b/nodes/nodes.py index a8dda7d..4f1d398 100644 --- a/nodes/nodes.py +++ b/nodes/nodes.py @@ -166,10 +166,11 @@ class WanImageToVideo_F2: vae.first_stage_model.encode = WanVaeWrapper_F2(vae.first_stage_model, end_image).encode la = vae.encode(concatenated) - print(1 + bool(valid_end_image)) + latent = torch.zeros([1, 16, ((length - 1) // 4) + (1 + bool(valid_end_image)), height // 8, width // 8], device=device) mask = torch.ones((1, 1, latent.shape[2], la.shape[-2], la.shape[-1]), device=device) + mask[:, :, :1] = 0.0 if valid_end_image: mask[:, :, -1:] = 0.0 @@ -183,4 +184,26 @@ class WanImageToVideo_F2: out_latent = {} out_latent["samples"] = latent - return (positive, negative, out_latent) \ No newline at end of file + return (positive, negative, out_latent) + +class GetImagesFromBatchRanged_F2: + @classmethod + def INPUT_TYPES(s): + return {"required": {"images": ("IMAGE", ), + "start_percent": ("FLOAT", {"default": 0.00, "min": 0.00, "max": 1.00, "step": 0.01, "round": 0.01}), + "end_percent": ("FLOAT", {"default": 1.00, "min": 0.00, "max": 1.00, "step": 0.01, "round": 0.01}), + }} + + RETURN_TYPES = ("IMAGE", ) + FUNCTION = "range" + + CATEGORY = "Flow2/Wan 2.1" + + def range(self, images, start_percent, end_percent): + count = len(images) + + start_index = round(count * start_percent) + end_index = round(count * end_percent) + + images = images[start_index:end_index] + return (images, ) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index e61f6aa..1ef984f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "ComfyUI-WanStartEndFramesNative" description = "Start and end frames video generation node that supports native ComfyUI." -version = "1.0.0" +version = "1.0.1" license = {file = "LICENSE"} dependencies = []