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
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 Name | Data Type | Required | Default Value | Value Range/Options | Description |
|---|---|---|---|---|---|
images | IMAGE | Yes | - | - | images (input parameter): Input an image batch. The node will extract the specified images from this batch. |
Control Parameters (Parameters)
| Parameter Name | Data Type | Required | Default Value | Value Range/Options | Description |
|---|---|---|---|---|---|
indexes | STRING | Yes | 0, 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 Name | Data Type | Description |
|---|---|---|
| IMAGE | IMAGE | IMAGE (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.
Get Images From Batch Indexed Node Source Code Link
The Get Images From Batch Indexed node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.