Nodes/ComfyUI-SAM3/SAM3 Create Box
ComfyUI Node

SAM3 Create Box

Build a box prompt from center and size

By PozzettiAndrea·Created 9 months ago·Updated about a month ago· 557
SAM3 Create Box
    • box_prompt
    center_x0.50
    center_y0.50
    width0.30
    height0.30
    is_positivetrue

    The numeric way to make a box prompt - the box equivalent of Create Point. Rather than drawing a rectangle on the image like the BBox Collector, you give it a center and a width/height, plus a positive/negative flag, and it emits one box prompt for SAM3 to segment inside. It's the node you use when a box should be defined by numbers instead of a mouse: a fixed region you hit every run, or a box whose coordinates come from somewhere upstream.

    One box on its own goes into SAM3 Combine Boxes, which merges up to five of these into the SAM3_BOXES_PROMPT that the segmentation nodes accept. So think of Create Box as one brick; Combine Boxes builds the wall.

    How it works

    It takes a normalized center and size - everything in 0-to-1 fractions of the image, so it's resolution-independent - and packages that as a single SAM3_BOX_PROMPT. The box is defined by its center point and its width and height, not by corner coordinates, which is a nicer mental model for "put a box this big, here." SAM3 then finds a precise mask for the object inside that rough rectangle. The positive flag says include; negative says exclude a region.

    The inputs and outputs that matter

    Five inputs, all straightforward:

    • center_x / center_y (default 0.5 each, range 0–1) - where the box's center sits, as fractions of width and height. 0.5, 0.5 is the middle.
    • width / height (default 0.3 each, range 0–1) - the box's size as a fraction of the image. 0.3 width means the box spans 30% of the image's width.
    • is_positive (default on) - on = a positive/include box; off = a negative/exclude box.

    Output is box_prompt (SAM3_BOX_PROMPT) - a single box. Feed it into SAM3 Combine Boxes to turn one or more of these into the plural SAM3_BOXES_PROMPT the segmentation nodes want.

    How to install it

    Ships with the pack. Manager: search SAM3, install the highest version. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/PozzettiAndrea/ComfyUI-SAM3.git
    cd ComfyUI-SAM3
    pip install -r requirements.txt --upgrade
    python install.py
    

    then restart. sam3.pt lives in ComfyUI/models/sam3/ for the segmentation nodes. The README warns about an experimental comfy-env/pixi one-click install.

    Common issues & troubleshooting

    The box is nowhere near the object. These are normalized fractions, not pixels, and the box is center-based. center_x/center_y place the middle of the box; width/height are total spans, not half-widths. If your subject is upper-left and small, think low center values with modest width/height.

    Box output won't plug into the segmentation node. Right - Create Box emits a single SAM3_BOX_PROMPT, but the segmentation nodes want the plural SAM3_BOXES_PROMPT. Run it through SAM3 Combine Boxes first, even if you only have one box.

    The mask still grabs the wrong thing inside the box. A loose box around a busy area gives SAM3 too much to choose from. Tighten width/height around the target, or add a point prompt to disambiguate.

    Doing this by hand is tedious. It is - for manual work, draw it with the BBox Collector instead. Create Box pays off when the numbers are fixed or computed, not when you're eyeballing.

    CategorySAM3/prompts

    Inputs (5)

    NameTypeDefaultDescription
    center_xFLOAT0.500–1Box center X (normalized 0-1)
    center_yFLOAT0.500–1Box center Y (normalized 0-1)
    widthFLOAT0.300–1Box width (normalized 0-1)
    heightFLOAT0.300–1Box height (normalized 0-1)
    is_positiveBOOLEANtrueTrue for positive (include), False for negative (exclude)

    Outputs (1)

    NameTypeDescription
    box_promptSAM3_BOX_PROMPT