VAE Latent Inspector (C2C):
The VAELatentInspectorMEC is a diagnostic tool designed to inspect latent tensors within Variational Autoencoders (VAEs) for sanity and statistical analysis. This node is particularly useful for identifying potential issues in the latent space, such as anomalies that could arise from VAE merge regressions, broken preprocessing, or blown-out/quantized latents before executing computationally expensive sampling processes. By analyzing the latent tensor, the VAELatentInspectorMEC provides detailed statistics including minimum, maximum, mean, standard deviation, and absolute mean per channel. It also counts occurrences of NaN (Not a Number) and Inf (Infinity) values, evaluates the dynamic range, and delivers an actionable verdict on the tensor's health. The verdict can indicate whether the tensor is "healthy," "low_contrast," "saturated," or "corrupt," helping you to quickly diagnose and address any issues in the latent space.
VAE Latent Inspector (C2C) Input Parameters:
latent
The latent parameter is the primary input for the VAELatentInspectorMEC node, representing the latent tensor that you wish to inspect. This tensor should be a four-dimensional float tensor with dimensions [B, C, H, W], where B is the batch size, C is the number of channels, H is the height, and W is the width. The latent tensor is analyzed to provide statistical insights and a health verdict. There are no specific minimum, maximum, or default values for this parameter, as it depends on the specific VAE model and data being used.
fail_on_corrupt
The fail_on_corrupt parameter is a boolean flag that determines the node's behavior when encountering a corrupt latent tensor. If set to True, the node will raise an error and halt execution if the latent tensor is found to be corrupt, containing NaN or Inf values. This can be useful for ensuring data integrity and preventing further processing of invalid data. The default value for this parameter is False, allowing the node to continue execution and return the verdict even if the tensor is corrupt.
VAE Latent Inspector (C2C) Output Parameters:
latent
The latent output parameter returns the original latent tensor that was inspected. This allows you to pass the tensor to subsequent nodes or processes without modification, ensuring that the inspection process is non-destructive.
info
The info output parameter provides a JSON-formatted string containing detailed statistical information about the latent tensor. This includes per-channel statistics such as minimum, maximum, mean, standard deviation, and absolute mean, as well as counts of NaN and Inf values. This information can be used for further analysis or debugging purposes.
verdict
The verdict output parameter is a string that provides an actionable assessment of the latent tensor's health. Possible verdicts include "healthy," "low_contrast," "saturated," and "corrupt," each indicating a different type of issue or confirmation of the tensor's integrity. This verdict helps you quickly understand the state of the latent tensor and decide on any necessary corrective actions.
nan_count
The nan_count output parameter is an integer representing the number of NaN (Not a Number) values found in the latent tensor. A high count may indicate data corruption or issues in the preprocessing pipeline.
inf_count
The inf_count output parameter is an integer representing the number of Inf (Infinity) values found in the latent tensor. Similar to nan_count, a high count of Inf values can signal potential problems in the data or model.
VAE Latent Inspector (C2C) Usage Tips:
- Use the
fail_on_corruptparameter set toTrueduring development to catch and address issues with corrupt latent tensors early in the process. - Regularly inspect latent tensors using this node to monitor the health of your VAE models, especially after significant changes or merges.
- Analyze the
infooutput to gain insights into the distribution and characteristics of your latent space, which can inform model tuning and data preprocessing strategies.
VAE Latent Inspector (C2C) Common Errors and Solutions:
LATENT contains NaN=<nan_count>, Inf=<inf_count>; refusing to pass through.
- Explanation: This error occurs when the
fail_on_corruptparameter is set toTrueand the latent tensor contains NaN or Inf values, indicating data corruption. - Solution: Investigate the source of the NaN or Inf values in your data preprocessing or model pipeline. Ensure that all inputs to the VAE are properly normalized and free of invalid values. Consider setting
fail_on_corrupttoFalseif you wish to bypass this check temporarily, but address the underlying issue to maintain data integrity.
