Run ComfyUI Easily with InstaSD

Skip the complex setup and run ComfyUI online. 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

Segment

Segment Node Documentation

Overview

The Segment node is a custom node in the ComfyUI-RMBG repository designed to perform advanced image segmentation. It leverages powerful machine learning models such as SAM and GroundingDINO to detect and segment objects within an image based on user-provided textual prompts. This node is particularly useful for object segmentation, allowing users to isolate specific elements of an image by either tag-style or natural language prompts.

Functionality

The Segment node offers precise object segmentation capabilities by using different models for detailed and accurate mask generation. It supports various features like mask blur, mask offset, background color application, and allows for the inversion of the mask output.

Inputs

  1. Image Input: The node accepts an image input that needs to be segmented.
  2. Prompt Input: A string input that describes the object or scene to segment. Prompts can be tag-style (e.g., "cat, dog") or natural language (e.g., "a person wearing a red jacket").
  3. SAM Model Selection: A selection of SAM models to use for segmentation. Different models offer varying levels of detail and processing capabilities.
  4. GroundingDINO Model Selection: Choose a GroundingDINO model for advanced object detection capabilities.
  5. Threshold (Optional): A floating-point value to adjust mask detection strength. Higher values result in stricter detection.
  6. Mask Blur (Optional): An integer value to apply Gaussian blur to the mask edges, reducing jaggedness.
  7. Mask Offset (Optional): An integer to expand or shrink the mask boundaries. Positive values expand, while negative values shrink the mask.
  8. Invert Output (Optional): A boolean option to invert the mask output.
  9. Background Selection: Choose the background type for the output image, either "Alpha" for transparency or "Color" for a specific color.
  10. Background Color (Optional): If "Color" is selected as the background type, specify the RGB color code for the background.

Outputs

The Segment node produces the following outputs:

  1. Processed Image: The image with the specified object or objects segmented according to the prompt, seamlessly integrated with the chosen background option.
  2. Mask Output: A binary mask that outlines the segmented object or objects, suitable for further processing or visualization.
  3. Mask Image: A visualization of the mask in image format, showing the segmented regions.

Usage in ComfyUI Workflows

The Segment node can be integrated into ComfyUI workflows where precise image editing and manipulation are required. Some potential use cases include:

  • Object Isolation: Extract specific objects from an image for separate processing or analysis.
  • Background Alteration: Change or remove backgrounds of images, especially useful for e-commerce or creative projects.
  • Visual Effects: Apply unique effects to isolated parts of images, enhancing creativity and design processes.

Special Features

  • Model Integration: Leverage state-of-the-art models like SAM and GroundingDINO to ensure high accuracy in segmentation tasks.

  • Text-Prompted Segmentation: Allows users to define object boundaries through descriptive text, enhancing flexibility and ease of use.

  • Adjustable Parameters: Users can finely tune mask strength, blur, and offset settings to meet specific requirements and image complexities.

  • Background Customization: Choose between transparent and color backgrounds, offering versatile options for output image styling.

Considerations

  • Model Selection: The choice of model affects both the processing speed and the detail of segmentation. Users should select models based on the complexity of the task and system resources.

  • Resolution Impact: Higher resolution images may require more processing power and time. Adjust the processing settings according to the available system specifications.

This node provides a powerful tool for users looking to perform precise and customizable object segmentation in ComfyUI, efficiently incorporating cutting-edge AI models into image processing workflows.

Want to try ComfyUI-RMBG without installing anything? Run ComfyUI online on InstaSD's cloud GPUs — no setup required.