Run ComfyUI Easily with InstaSD

Skip the complex setup. InstaSD helps creative professionals build workflows and deploy them to the world:

  • One-click deployment
  • Any model, any node
  • Powerful GPUs for rapid iteration
Get Started

AILab_ReferenceLatentMask

AILab_ReferenceLatentMask Node Documentation

Overview

The AILab_ReferenceLatentMask node is a specialized tool in the ComfyUI ecosystem designed to enhance inpainting tasks using the Flux Kontext model. This node facilitates precise region conditioning by leveraging a reference latent and mask to target specific inpainting areas within an image. This targeted approach allows for more accurate and refined inpainting results, making it a powerful tool for image editing and restoration workflows.

Functionality

What This Node Does

The AILab_ReferenceLatentMask node is used to prepare inpainting conditioning by:

  • Generating a modified mask for inpainting by allowing mask expansion and edge blurring.
  • Incorporating a reference latent (an encoded image from a Variational Autoencoder [VAE]) into the inpainting conditioning process.
  • Allowing generation of new content exclusively within the masked area if desired.

Inputs

The node accepts the following inputs:

  • Conditioning: The base conditioning input required for the inpainting task.
  • Latent: An encoded latent image obtained from a VAE. This provides the foundational visual information for the task.
  • Mask: The area within the image targeted for inpainting. White regions in the mask indicate where the inpainting occurs.
  • Expand: An integer value to grow (positive values) or shrink (negative values) the mask boundary. The default value is 5, and it can range from -64 to 64.
  • Blur: A floating-point value specifying the amount of blur applied to mask edges, which helps soften transitions between inpainted and original areas. The default value is 3.0, with a range of 0.0 to 64.0.
  • Mask Only: A boolean option that, when true, ensures new content is generated only within the masked region. The default setting is true.

Outputs

The node produces the following outputs:

  • Conditioning: The conditioning output, modified to include the latent and processed mask information.
  • Latent: The latent output, consisting of the modified latent image samples, with an optional noise mask if mask-only generation is requested.
  • Mask: The processed mask, which may have been expanded or blurred as specified by the input parameters.

Usage in ComfyUI Workflows

How It Might Be Used

The AILab_ReferenceLatentMask node is best utilized in workflows where targeted inpainting is required. For instance, users might employ this node when they need to:

  • Restore or edit specific regions of an image with high precision.
  • Seamlessly integrate new content into existing images, using expanded and softened masks to ensure natural transitions.
  • Utilize encoded latent images to facilitate reconstructive efforts in an intelligent and contextually aware manner.

Example Workflow

  1. Load the Node: In a ComfyUI workflow, add the AILab_ReferenceLatentMask node from the inpainting category.
  2. Connect Inputs: Attach existing conditioning, latent, and mask elements to the corresponding inputs on the node.
  3. Adjust Parameters: Fine-tune the expand, blur, and mask_only settings to suit the specific requirements of the task.
  4. Integrate Outputs: Use the outputs from the node to direct further processing or pass along to subsequent nodes in the workflow for additional image editing steps.

Special Features and Considerations

  • Precision Control: The node's ability to alter mask boundaries and apply blur offers refined control over where and how inpainting is applied.
  • Latent Integration: By incorporating latent images extracted from VAEs, the node leverages prior image data to inform and enhance inpainting output.
  • Conditional Configurability: Users can choose to limit new content generation strictly to the masked areas, providing flexibility and precise control over the inpainting process.
  • Performance Optimization: The node is optimized for performance, making it suitable for both simple and complex inpainting tasks across varied image contexts.

Overall, the AILab_ReferenceLatentMask node is a versatile and powerful tool for users seeking advanced inpainting capabilities within their ComfyUI workflows. By providing enhanced control and integration features, this node aids in producing high-quality, contextually aware image edits.