ComfyUI > Nodes > ComfyUI 1hewNodes > Mask to SAM3 Box

ComfyUI Node: Mask to SAM3 Box

Class Name

1hew_MaskToSam3Box

Category
1hewNodes/conversion
Author
1hew (Account age: 1113days)
Extension
ComfyUI 1hewNodes
Latest Updated
2026-04-17
Github Stars
0.03K

How to Install ComfyUI 1hewNodes

Install this extension via the ComfyUI Manager by searching for ComfyUI 1hewNodes
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI 1hewNodes 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
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Mask to SAM3 Box Description

Converts masks to SAM3-compatible bounding box prompts for AI model training and inference.

Mask to SAM3 Box:

The 1hew_MaskToSam3Box node is designed to convert a given mask into bounding box prompts suitable for use with the SAM3 (Segment Anything Model 3) framework. This node is particularly useful for AI artists who need to transform mask data into a format that can be easily interpreted by machine learning models for tasks such as object detection or segmentation. By processing the mask data, the node generates bounding boxes that encapsulate the areas of interest within the mask, allowing for more precise and efficient model training or inference. The node offers flexibility in how these bounding boxes are generated, either by merging all detected regions into a single box or by creating separate boxes for each distinct region. This capability is essential for artists and developers looking to streamline their workflow and enhance the accuracy of their AI models.

Mask to SAM3 Box Input Parameters:

mask

The mask parameter is a tensor that represents the input mask data. This mask is used to identify the regions of interest that will be converted into bounding boxes. The mask should be a 2D or 3D tensor, where each element indicates whether a particular pixel is part of the region of interest. The mask's dimensions directly impact the size and number of bounding boxes generated. There are no specific minimum or maximum values for this parameter, but it should be a valid tensor that the node can process.

condition

The condition parameter determines the labeling of the generated bounding boxes. It accepts two options: "positive" and "negative". When set to "positive", the bounding boxes are labeled as positive regions, indicating areas of interest. Conversely, when set to "negative", the boxes are labeled as negative regions. This parameter influences how the bounding boxes are interpreted by subsequent processes or models. The default value is "positive".

output_mode

The output_mode parameter specifies how the bounding boxes should be generated from the mask. It offers two options: "merge" and "separate". In "merge" mode, all detected regions within the mask are combined into a single bounding box, which is useful for simplifying the output when multiple regions are closely located. In "separate" mode, each distinct region within the mask is converted into its own bounding box, providing a more detailed representation of the mask's contents. The default value is "merge".

Mask to SAM3 Box Output Parameters:

SAM3_BOXES_PROMPT

The SAM3_BOXES_PROMPT output parameter provides the generated bounding box prompts in a format compatible with the SAM3 framework. This output consists of a list of dictionaries, each containing the bounding boxes and their corresponding labels. The bounding boxes are represented in a normalized format, making them ready for use in AI models that require input in this specific structure. This output is crucial for integrating the node's functionality into larger workflows involving object detection or segmentation tasks.

Mask to SAM3 Box Usage Tips:

  • To achieve the best results when using the 1hew_MaskToSam3Box node, ensure that your input mask is well-defined and accurately represents the regions of interest. This will help in generating precise bounding boxes.
  • Experiment with the output_mode parameter to see which setting best suits your needs. Use "merge" for a simplified output when regions are close together, and "separate" for detailed outputs when distinct regions need to be individually identified.

Mask to SAM3 Box Common Errors and Solutions:

Invalid mask tensor

  • Explanation: This error occurs when the input mask is not a valid tensor or does not have the correct dimensions.
  • Solution: Ensure that the mask is a 2D or 3D tensor and that it is properly formatted before passing it to the node.

No regions detected in mask

  • Explanation: This error happens when the mask does not contain any regions that can be converted into bounding boxes.
  • Solution: Verify that the mask correctly highlights the regions of interest and that the thresholding is set appropriately to detect these regions.

Output mode not recognized

  • Explanation: This error arises when an invalid value is provided for the output_mode parameter.
  • Solution: Check that the output_mode is set to either "merge" or "separate" and that there are no typos in the parameter value.

Mask to SAM3 Box Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI 1hewNodes
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.

Mask to SAM3 Box