ComfyOnline
ReActorMaskHelper

ComfyUI-ReActor Introduction

ComfyUI-ReActor is a powerful extension for ComfyUI, specializing in fast, high-quality face swapping and face enhancement. It integrates advanced face detection, restoration, and manipulation technologies into an intuitive, node-based workflow, allowing users to achieve state-of-the-art results in image editing and AI art.

  • Repository: Gourieff/ComfyUI-ReActor
  • Node Count: 15+ custom nodes (including face swap, blending, mask helper, etc.)
  • Start 566
  • Author: Gourieff

ReActorMaskingHelper Introduction

The ReActorMaskHelper node (class: MaskHelper) is a core component of ComfyUI-ReActor, designed to help users create, refine, and apply masks for face-swapping or other compositional tasks. It provides a comprehensive and flexible masking workflow, leveraging both bounding box (BBox), segmentation, and SAM (Segment Anything Model) techniques to accurately isolate facial regions or other objects of interest.

This node is essential when you need precise control over which parts of the image are affected by the swap, restoration, or compositing, ensuring natural-looking results even in complex scenes.


ReActorMaskingHelper Input Overview (List Format)

  • image (IMAGE): The original input image.
  • swapped_image (IMAGE): The face-swapped or modified image to composite.
  • bbox_model_name (bbox/SEG models, auto-detected): Model for object/face detection, such as YOLO or segmentation models.
  • bbox_threshold (FLOAT, 0.0–1.0): Detection confidence threshold.
  • bbox_dilation (INT, -512 ~ 512): Dilate or shrink the detected bounding box.
  • bbox_crop_factor (FLOAT, ≥1.0): Area around the bounding box to crop or expand.
  • bbox_drop_size (INT, 1 ~ 8192): Minimum size to keep detected objects.
  • sam_model_name (SAM model, auto-detected): Segment Anything Model checkpoint name.
  • sam_dilation (INT, -512 ~ 512): Additional dilation/erosion for segmentation.
  • sam_threshold (FLOAT, 0.0–1.0): Confidence for SAM mask generation.
  • bbox_expansion (INT, 0 ~ 1000): Further expand bounding box before segmentation.
  • mask_hint_threshold (FLOAT, 0.0–1.0): Threshold for hint mask extraction.
  • mask_hint_use_negative ("False", "Small", "Outter"): Mask hint mode for background or negative selection.
  • morphology_operation ("dilate", "erode", "open", "close"): Morphological operation for mask cleaning.
  • morphology_distance (INT, 0 ~ 128): Distance for morphological operation.
  • blur_radius (INT, 0 ~ 48): Blur radius for feathering the mask edge.
  • sigma_factor (FLOAT, 0.01 ~ 3.0): Standard deviation for blur smoothing.
  • mask_optional (MASK, optional): Pre-existing mask to combine or refine (optional).

ReActorMaskingHelper Features

  • Multi-Stage Masking: Combines bounding box, segmentation, and SAM for robust mask extraction.
  • Batch Processing: Handles both single and batch image inputs seamlessly.
  • Morphological Controls: Allows mask dilation, erosion, opening, closing for precise refinement.
  • Blurring/Feathering: Gaussian blur at the mask edge for smooth transitions.
  • Adaptive Pasting: Automatically cuts and pastes the swapped region back into the original image using the refined mask.
  • Caching: Efficiently caches loaded models for faster repeated use.
  • Preview Outputs: Provides both the raw and blurred mask for visualization and debugging.

ReActorMaskHelper Usage Tips

  • Choose the Right Model: For most faces, YOLO or RetinaFace models work well for bbox_model_name. For general objects, try segmentation models.
  • SAM Model: Select a SAM model that matches your GPU/CPU resources. Larger models (e.g., vit_h) offer higher accuracy but consume more memory.
  • Refine with Morphology: Use dilate to expand the mask or erode to shrink it. open and close help remove small artifacts or fill gaps.
  • Feathering: Increase blur_radius and adjust sigma_factor for softer mask edges, which helps blend swapped faces more naturally.
  • Combine with Pre-masks: Use mask_optional to layer or refine masks, especially useful when reprocessing or making complex composites.
  • Batch Operations: The node will process all images in a batch, automatically aligning mask and image shapes.
  • Debugging: Use the mask preview outputs to understand how your settings affect the final mask.

The ReActorMaskHelper is a must-have when you want pixel-perfect control over mask generation for face swapping, blending, or any region-specific image manipulation within ComfyUI-ReActor. Experiment with its many settings to achieve professional, seamless results!

related extension: