ComfyUI-KJNodes
Run ComfyUI Easily with InstaSD
Skip the complex setup. InstaSD helps creative professionals build workflows and deploy them to the world:
- One-click deployment
- Any model, any node
- Powerful GPUs for rapid iteration
Available Nodes
GetImageRangeFromBatch
GetImageRangeFromBatch Node
Overview
The GetImageRangeFromBatch node is part of the ComfyUI KJNodes repository. This node allows users to extract a specific range of images from a batch of images or masks. It is particularly useful in scenarios where only a subset of images or masks from a larger batch is required for further processing or visualization.
Inputs
The GetImageRangeFromBatch node accepts the following inputs:
-
start_index: An integer specifying the starting index of the range of images or masks to be extracted. The index is zero-based, meaning that an index of
0refers to the first image or mask in the batch. If set to-1, the node will automatically calculate the starting index to retrieve the lastnum_framesimages or masks. -
num_frames: An integer defining the number of images or masks to extract starting from the
start_index. It must be greater than or equal to1. -
images (optional): A batch of images from which the specified range of images will be extracted. This should be in the format of a ComfyUI image type.
-
masks (optional): A batch of masks from which the specified range will be extracted. This should be in the format of a ComfyUI mask type.
Both images and masks are optional inputs, allowing the node to operate on either images, masks, or both. If neither is provided, the node will not function as expected.
Outputs
The GetImageRangeFromBatch node produces the following outputs:
-
images: The extracted range of images from the input batch, if
imageswere provided as an input. -
masks: The extracted range of masks from the input batch, if
maskswere provided as an input.
If only one of the optional inputs (images or masks) is provided, the node will return None for the other. Therefore, both outputs can be utilized separately in subsequent nodes within the ComfyUI workflow.
Usage in ComfyUI Workflows
The GetImageRangeFromBatch node is useful in scenarios where users need to isolate a specific sequence of images or masks from a larger batch. Applications within image processing and generation workflows could include:
- Selecting a sequence of frames from an animation or video batch for additional effects or transformations.
- Extracting a subset of training images or masks for machine learning purposes.
- Isolating a portion of a batch for preview or saving, which can be especially useful when handling large datasets.
Special Features or Considerations
-
Automatic Index Calculation: By setting the
start_indexto-1, the node automatically calculates the starting index to retrieve the lastnum_framesfrom the batch. This functionality is particularly useful when users are interested in the most recent frames or masks added to a batch. -
Range Validation: The node includes built-in checks to ensure the specified index range is within the bounds of the input batch size. If the calculated or provided indices are out of range, the node will raise an error. This feature helps avoid common errors when working with dynamic batch sizes.
-
Dual-Functionality: Capable of handling both images and masks, the node can extract range subsets for either input type. This flexibility allows it to fit seamlessly into various ComfyUI workflows where images and masks may be processed in tandem.
The GetImageRangeFromBatch node offers a straightforward way to manage and manipulate batches of images or masks within ComfyUI's versatile environment, accommodating numerous use cases demanding precision and control in image processing tasks.