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
Get Started

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:

  1. 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 0 refers to the first image or mask in the batch. If set to -1, the node will automatically calculate the starting index to retrieve the last num_frames images or masks.

  2. 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 to 1.

  3. 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.

  4. 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:

  1. images: The extracted range of images from the input batch, if images were provided as an input.

  2. masks: The extracted range of masks from the input batch, if masks were 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_index to -1, the node automatically calculates the starting index to retrieve the last num_frames from 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.