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

InsertImageBatchByIndexes

InsertImageBatchByIndexes Node Documentation

Overview

The InsertImageBatchByIndexes node is a processing component in ComfyUI designed to facilitate the insertion of image batches back into their original sequence. This node is particularly useful in workflows where images are filtered out for certain operations and need to be reinserted into their initial positions in the image sequence. The primary use case for this node involves its integration with the FilterZeroMasksAndCorrespondingImages node.

Functionality

This node takes a batch of images and inserts another set of images at specified indexes within the batch. It ensures that images to be inserted are placed at their correct positions based on the provided index list, preserving the original order where applicable. This functionality is crucial for workflows that manipulate or modify image sequences and need to maintain consistency with their original order.

Inputs

The InsertImageBatchByIndexes node accepts the following inputs:

  1. Images:

    • Type: IMAGE
    • Description: The original batch of images into which other images will be inserted.
  2. Images to Insert:

    • Type: IMAGE
    • Description: The batch of images that are to be inserted into the original image sequence.
  3. Insert Indexes:

    • Type: INDEXES
    • Description: A list of indices specifying where each of the Images to Insert should be placed in the Images batch. The length of this list should match the number of images in the Images to Insert.

Outputs

The node produces the following output:

  1. Images After Insert:
    • Type: IMAGE
    • Description: The updated batch of images with the Images to Insert placed according to the specified Insert Indexes, preserving the original order elsewhere.

Usage in ComfyUI Workflows

The InsertImageBatchByIndexes node is typically used in workflows that require the temporary removal of certain images for processing or filtering, especially in scenarios involving masking operations. For instance, after using the FilterZeroMasksAndCorrespondingImages node to remove images with zero masks, this node can be employed to reinsert the filtered images back into their original sequence positions.

Example Workflow

  1. Initial Image Batch: Begin with an original batch of images.
  2. Filtering Step: Utilize nodes like FilterZeroMasksAndCorrespondingImages to filter out specific images, which results in a modifications on the batch.
  3. Reinsertion Using InsertImageBatchByIndexes: Following processing, use the InsertImageBatchByIndexes node to reinsert filtered out images such as those with zero masks back into their original index locations within the batch.

Special Features and Considerations

  • Index Alignment: It is crucial that the number of images in the Images to Insert matches the number of indices in Insert Indexes. A mismatch will prompt a warning and the node will not execute as intended.
  • Order Preservation: This node ensures that the order of the original images is preserved while integrating new images at specified positions.
  • Error Handling: In cases where the lengths of Images to Insert and Insert Indexes do not align, the node will issue a warning and maintain the original image sequence unchanged.

This node is a powerful tool for maintaining and reconstructing image sequences in complex workflows requiring selective image manipulation and reintegration.