ComfyUI > Nodes > ComfyUI-Image-Filters > AdaIN Filter (Latent)

ComfyUI Node: AdaIN Filter (Latent)

Class Name

AdainFilterLatent

Category
latent/filters
Author
spacepxl (Account age: 295days)
Extension
ComfyUI-Image-Filters
Latest Updated
2024-06-22
Github Stars
0.08K

How to Install ComfyUI-Image-Filters

Install this extension via the ComfyUI Manager by searching for ComfyUI-Image-Filters
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI-Image-Filters in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • High-speed GPU machines
  • 200+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 50+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

AdaIN Filter (Latent) Description

Perform adaptive instance normalization on latent representations for style transfer and image synthesis by matching statistical properties and blending based on a factor.

AdaIN Filter (Latent):

The AdainFilterLatent node is designed to perform adaptive instance normalization (AdaIN) on latent representations, which are intermediate data structures used in neural networks. This node allows you to adjust the style of one latent representation (the target) to match the statistical properties of another latent representation (the reference). By doing so, it enables the transfer of stylistic features from the reference to the target, which can be particularly useful in tasks such as style transfer and image synthesis. The node achieves this by normalizing the target latent's mean and standard deviation to match those of the reference latent, and then blending the adjusted target with the original target based on a specified factor. This process helps in creating more coherent and visually appealing results by harmonizing the styles between different latent representations.

AdaIN Filter (Latent) Input Parameters:

latents

This parameter represents the target latent representation that you want to adjust. It is a required input and should be of type LATENT. The latent contains the intermediate data that will be normalized and blended with the reference latent.

reference

This parameter represents the reference latent representation whose statistical properties (mean and standard deviation) will be used to adjust the target latent. It is a required input and should be of type LATENT. The reference latent provides the stylistic features that will be transferred to the target latent.

filter_size

This parameter determines the size of the filter used for calculating the local mean and standard deviation of the latents. It is an integer value with a default of 1, a minimum of 1, and a maximum of 128. The filter size impacts the granularity of the normalization process, with larger sizes leading to more global adjustments and smaller sizes focusing on more localized adjustments.

factor

This parameter controls the blending factor between the original target latent and the adjusted target latent. It is a float value with a default of 1.0, a minimum of -10.0, and a maximum of 10.0, with a step size of 0.01. A factor of 1.0 means full application of the reference style, while a factor of 0.0 means no change to the original target latent. Negative values can invert the effect, and values greater than 1.0 can exaggerate the style transfer.

AdaIN Filter (Latent) Output Parameters:

LATENT

The output is a latent representation that has been adjusted to incorporate the stylistic features of the reference latent. This output retains the structure of the original target latent but with modified statistical properties to match those of the reference latent. The result is a harmonized latent that blends the styles of both the target and reference latents.

AdaIN Filter (Latent) Usage Tips:

  • To achieve subtle style transfer, use a small filter_size and a factor close to 0.5.
  • For more pronounced style changes, increase the filter_size and set the factor closer to 1.0.
  • Experiment with negative factor values to explore creative and unexpected style inversions.
  • Use this node in conjunction with other latent manipulation nodes to refine and enhance the final output.

AdaIN Filter (Latent) Common Errors and Solutions:

RuntimeError: Expected 4-dimensional input for 4-dimensional weight [64, 3, 7, 7], but got 3-dimensional input of size [3, 224, 224] instead

  • Explanation: This error occurs when the input latent does not have the expected dimensions.
  • Solution: Ensure that the input latents are correctly formatted as 4-dimensional tensors with the shape [B, C, H, W].

ValueError: filter_size must be between 1 and 128

  • Explanation: This error occurs when the filter_size parameter is set outside the allowed range.
  • Solution: Adjust the filter_size parameter to be within the range of 1 to 128.

TypeError: factor must be a float

  • Explanation: This error occurs when the factor parameter is not provided as a float.
  • Solution: Ensure that the factor parameter is specified as a float value, such as 1.0 or 0.5.

AdaIN Filter (Latent) Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI-Image-Filters
RunComfy

© Copyright 2024 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals.