Get Latent Size & Count(GetLatentSizeAndCount)
This node works by checking the shape of the `"samples"` tensor in the input `latent` dictionary.
Get Latent Size And Count
The Get Latent Size & Count node works by examining the shape of the "samples" tensor within the input latent dictionary.
The Get Latent Size & Count node is a utility tool for analyzing and passing latent space data. Its core function is to read the dimensional information of the input latent tensor and output it as separate integer values, while simultaneously passing the original latent data through unchanged for continued use in subsequent workflow steps.
Node Functionality
This node operates by inspecting the shape of the "samples" tensor within the input latent dictionary. It can automatically identify and handle two common latent tensor formats: one is a five-dimensional tensor containing a time dimension (used for video or animation), formatted as [batch_size, channels, frames, height, width]; the other is a standard four-dimensional image tensor, formatted as [batch_size, channels, height, width]. For four-dimensional inputs, the frames output will be set to 0.
Node Parameter Description - Get Latent Size & Count
Inputs
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
latent | LATENT | Yes | - | - | The latent space data to be output as-is, used for workflow connectivity. |
Outputs
| Parameter Name | Data Type | Description |
|---|---|---|
| latent | LATENT | The latent space data output as-is, used for workflow connectivity. |
| batch_size | INT | The output batch size, i.e., the number of samples processed simultaneously. |
| channels | INT | The output number of channels, i.e., the depth of the latent feature map. |
| frames | INT | The output number of frames. For static images, this value is 0. |
| height | INT | The height of the output latent feature map (in pixel blocks). |
| width | INT | The width of the output latent feature map (in pixel blocks). |
Usage Scenarios
This node is very useful when building workflows that require dynamic parameter adjustment based on image or video dimensions. For example, you can connect it before a VAE Decode node to obtain the height and width of the latent map, then feed these values into an Empty Latent Image node to ensure the generation of a new latent space that matches the dimensions of the decoded image, thereby creating a multi-stage generation pipeline with consistent sizing.
Notes
Please note that this node requires the input latent tensor shape to be either four-dimensional or five-dimensional; otherwise, an error will occur. It does not modify the content of the input latent data, only reads and passes it through.
Get Latent Size & Count Node Source Code Link
The Get Latent Size & Count node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.