Nodes/comfyui-fvmtools/K2 Region from BBox
ComfyUI Node

K2 Region from BBox

Stop drawing, start detecting

By ping1979ping·Created 6 months ago·Updated about a month ago· 0
K2 Region from BBox
  • regions
  • bboxes
  • bounding_box
  • regions
nameSubject
prompt
bbox_index0
bbox_formatxyxy
reference_width1024
reference_height1024
grow_px0
roleauto
priority100
identity_prompt

K2 Region from BBox turns a detector's bounding box into a K2 region. Where K2 Region asks you to type pixel coordinates, this node reads them from a detector - YOLO, the Krea 2 bbox prompting from KJNodes' Ideogram-style prompt builder, or this pack's own person selectors - and hands you a ready region with a name, a prompt, and a role.

This is the automation bridge for the K2 Lab suite in comfyui-FVMtools. If you're doing character-consistent multi-person work, you don't want to hand-draw the same boxes every run; you want a detector to find the faces and bodies, and this node to convert those detections into the regions the attention router understands.

The inputs that matter

  • name and prompt - same as on K2 Region: the label used in spatial instructions and reports, and what appears inside the box.
  • bboxes (KJNodes-style BBOX list) or bounding_box (standard BOUNDING_BOX) - the detection input. bounding_box takes precedence when both are connected.
  • bbox_index - which box in the list to use, zero-based. Out of range clamps to the last entry.
  • bbox_format - xyxy (left/top/right/bottom) is what YOLO, BOUNDING_BOX, and the KJ prompt builder emit; xywh is left/top/width/height. auto tries xyxy first and only falls back to xywh when xyxy yields an impossible box - but it can't always tell them apart, so set it explicitly when you know the format.
  • reference_width / reference_height - the canvas the normalized (0..1) coordinates are expanded against. Must match the render size.
  • grow_px - expand (positive) or shrink (negative) every side of the box. Handy when a detector's tight face box needs to become a head or body region.
  • role and priority - same meaning as on K2 Region: subject/background/auto, and compile/face-claim order (not strength).

Chain through regions like any other region node; identity_prompt is available for face descriptions.

Typical wiring

Detector → BBOX → K2 Region from BBox → K2 Compose. Run it, look at the result with K2 Region Preview, and adjust grow_px until the box actually covers what you meant. Detector boxes are usually tighter than you want for a subject region - a face detector gives you a face box, and your prompt probably describes the whole person, so grow_px is where you'll spend your time.

Install

Same as the rest of the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/ping1979ping/comfyui-FVMtools

Restart ComfyUI, find it under FVM Tools/K2. No extra Python dependencies; the detector itself is whatever your workflow already uses.

CategoryFVM Tools/K2

Inputs (13)

NameTypeDefaultDescription
nameSTRINGSubjectLabel for this detected region. Must be unique.
promptSTRINGWhat should appear inside the detected box.
bbox_indexINT00–64Zero-based index into the bbox list. Out-of-range clamps to the last entry.
bbox_formatCOMBOxyxyxyxy = left/top/right/bottom (what YOLO, BOUNDING_BOX and the KJ prompt builder emit). xywh = left/top/width/height. auto tries xyxy first and only falls back to xywh when that yields an impossible box — it cannot always tell them apart, so set the format explicitly when you know it.
reference_widthINT102416–16384Canvas width used to expand normalized coordinates.
reference_heightINT102416–16384Canvas height for normalized coordinates. Must match the render size.
grow_pxINT0-512–512Expand (or shrink) every side.
roleCOMBOautosubject / background / auto — same meaning as on K2 Region.
priorityINT100-1000–1000Higher compiles first and claims ambiguous faces first.
regionsoptK2_REGIONChain input: previously defined regions.
bboxesoptBBOXKJNodes-style BBOX list.
bounding_boxoptBOUNDING_BOXStandard BOUNDING_BOX input. Takes precedence over bboxes.
identity_promptoptSTRINGFace/identity description for this region.

Outputs (1)

NameTypeDescription
regionsK2_REGION