KJNodes/imagegenerated

Get Images From Batch Indexed(GetImagesFromBatchIndexed)

This node receives a tensor of type IMAGE as input, which represents a batch of images.

Get Images From Batch Indexed

images
IMAGE
indexes
0, 1, 2
KJNodes

The Get Images From Batch Indexed node receives a tensor of type IMAGE as input, which represents a batch of images.

The Get Images From Batch Indexed node is a tool for precisely extracting specific images from an image batch. Its core function is to filter out corresponding images from a batch containing multiple images based on a list of indices provided by the user, and output them as a new image batch. This operation is very useful for scenarios that require processing batches of images but only focus on a subset of the results.

Node Functionality

This node receives a tensor of type IMAGE as input, representing an image batch. The user specifies the positional indices of the images to be extracted within the batch via a comma-separated string. Internally, the node parses the input string into a list of integers and uses PyTorch's indexing functionality to select the corresponding image tensors from the original batch tensor. Finally, the selected images are output as a new batch, also of type IMAGE.

Node Parameter Description - Get Images From Batch Indexed

Connection Inputs (Inputs)

Parameter NameData TypeRequiredDefault ValueValue Range/OptionsDescription
imagesIMAGEYes--images (input parameter): Input an image batch. The node will extract the specified images from this batch.

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueValue Range/OptionsDescription
indexesSTRINGYes0, 1, 2-indexes (input parameter): Specifies the indices of the images to extract, input as a comma-separated string, e.g., "0, 3, 5".

Output

Parameter NameData TypeDescription
IMAGEIMAGEIMAGE (output parameter): Outputs a new image batch composed of the selected images.

Usage Scenario

In an image generation or post-processing workflow, if you have generated a batch of images containing multiple variants but only need the 1st, 3rd, and 5th images for the next steps like upscaling or style transfer, you can use this node. Simply connect the entire image batch to the images input and enter "0, 2, 4" (indices start from 0) in the indexes field. The node will then output a new batch containing only these three images for processing by subsequent nodes.

Notes

Please note that the provided index values must be valid integers and cannot exceed the actual number of images in the input batch; otherwise, a runtime error will occur. The index string supports flexible formats, such as "0,2,4" or "0, 2, 4", but it must be ensured that it can be correctly parsed into integers.

The Get Images From Batch Indexed node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…