K2 Region from BBox
Stop drawing, start detecting
- regions
- bboxes
- bounding_box
- regions
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
nameandprompt- same as on K2 Region: the label used in spatial instructions and reports, and what appears inside the box.bboxes(KJNodes-style BBOX list) orbounding_box(standard BOUNDING_BOX) - the detection input.bounding_boxtakes 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;xywhis left/top/width/height.autotries 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.roleandpriority- 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.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| name | STRING | Subject | Label for this detected region. Must be unique. |
| prompt | STRING | What should appear inside the detected box. | |
| bbox_index | INT | 00–64 | Zero-based index into the bbox list. Out-of-range clamps to the last entry. |
| bbox_format | COMBO | xyxy | xyxy = 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_width | INT | 102416–16384 | Canvas width used to expand normalized coordinates. |
| reference_height | INT | 102416–16384 | Canvas height for normalized coordinates. Must match the render size. |
| grow_px | INT | 0-512–512 | Expand (or shrink) every side. |
| role | COMBO | auto | subject / background / auto — same meaning as on K2 Region. |
| priority | INT | 100-1000–1000 | Higher compiles first and claims ambiguous faces first. |
| regionsopt | K2_REGION | Chain input: previously defined regions. | |
| bboxesopt | BBOX | KJNodes-style BBOX list. | |
| bounding_boxopt | BOUNDING_BOX | Standard BOUNDING_BOX input. Takes precedence over bboxes. | |
| identity_promptopt | STRING | Face/identity description for this region. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| regions | K2_REGION | — |