Add first_frame and last_frame outputs to I2VChainHelper
This commit is contained in:
@@ -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).
|
||||
|
||||
+8
-5
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user