From eb58f520eee7c0e70f638a1d08aab243489cc7e2 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 22 Jan 2026 23:35:07 +0700 Subject: [PATCH] Add first_frame and last_frame outputs to I2VChainHelper --- README.md | 2 ++ i2v_chain_helper.py | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index deb412e..adbdd67 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,8 @@ pip install -r requirements.txt - **Outputs**: - `trimmed_images`: The filtered and potentially shortened batch. - `frame_count`: Number of images in the trimmed batch. + - `first_frame`: The first image of the trimmed batch (for convenience). + - `last_frame`: The last "good" image of the trimmed batch (useful for I2V chaining). ## Credits This project follows practices from [ComfyUI-FrameIO](https://github.com/example/ComfyUI-FrameIO) and uses logic compatible with [ComfyUI-FaceAnalysis](https://github.com/example/comfyanonymous/comfyui_faceanalysis). diff --git a/i2v_chain_helper.py b/i2v_chain_helper.py index 69d64b9..e79bc7d 100644 --- a/i2v_chain_helper.py +++ b/i2v_chain_helper.py @@ -43,14 +43,14 @@ class I2VChainHelper: } } - RETURN_TYPES = ("IMAGE", "INT") - RETURN_NAMES = ("trimmed_images", "frame_count") + RETURN_TYPES = ("IMAGE", "INT", "IMAGE", "IMAGE") + RETURN_NAMES = ("trimmed_images", "frame_count", "first_frame", "last_frame") FUNCTION = "execute" CATEGORY = "I2VChain" def execute(self, images, analysis_models, min_face_similarity, min_eyes_openness): if images.shape[0] == 0: - return (images, 0) + return (images, 0, images, images) # 1. Get reference embedding from the first frame ref_img = tensor_to_pil(images[0]) @@ -58,7 +58,7 @@ class I2VChainHelper: if ref_embed is None: print("I2VChainHelper: No face detected in the first frame. Returning empty batch.") - return (images[:0], 0) + return (images[:0], 0, images[:0], images[:0]) ref_embed = ref_embed / np.linalg.norm(ref_embed) @@ -103,7 +103,10 @@ class I2VChainHelper: pbar.update(1) trimmed_images = images[:last_good_index + 1] - return (trimmed_images, trimmed_images.shape[0]) + first_frame = trimmed_images[0:1] + last_frame = trimmed_images[-1:] + + return (trimmed_images, trimmed_images.shape[0], first_frame, last_frame) NODE_CLASS_MAPPINGS = { "I2VChainHelper": I2VChainHelper