Nodes/comfyui-fvmtools/K2 Region Builder
ComfyUI Node

K2 Region Builder

Stop typing pixel coordinates, start drawing boxes

By ping1979ping·Created 6 months ago·Updated about a month ago· 0
K2 Region Builder
    • regions
    • loras
    • global_prompt
    • width
    • height
    • report
    width1024
    height1024
    global_prompt
    layout{ "version": 1, "canvas": { "width": 1024, "height": 1024 }, "boxes": [] }

    K2 Region Builder is the whole point of the K2 Lab suite in one node: it replaces the long chain of K2 Region nodes with a visual editor. You press Edit layout, a detached window opens, you drag boxes onto a canvas, type a prompt and an identity prompt into each, attach any number of LoRAs per box with their own strength and routing mode - and it hands K2 Compose everything it needs: regions, loras, global_prompt, width, and height.

    If you've used the standalone K2Lab desktop app from the Krea 2 regional-prompting scene, this is that workflow brought back into the graph. The author of this pack reimplemented it as nodes because that's the one thing K2Lab's own author explicitly wasn't going to do ("I don't like ComfyUI" is a direct quote from the K2Lab thread).

    The editor window

    The window is split 2/3 canvas, 1/3 inputs - regions list on top, details of the selection below. Draw on empty space to make a region, Ctrl-drag to stack one on top of an existing region, Alt-click to reach a box underneath. Eight handles resize; Fit spreads things out; the up-arrow in the list reorders, and order decides compile order. Esc closes. The Backdrop button pulls your latest render from the output folder behind the canvas so you can place boxes against a real composition, with a Dim slider to keep box edges readable.

    The fiddly bits are handled for you. Overlapping regions are resolved by weighted picking - smallest box wins, so a full-canvas background box can never block a small subject box. And typing doesn't rebuild the panel, so you don't lose text-field focus on every keystroke.

    The part other editors get wrong

    Boxes are stored normalized (0..1) and rescaled shape-preserving whenever you change width or height: a square box stays square, its relative centre stays put, and if it no longer fits the canvas it shrinks evenly instead of being squashed. That's the difference between this and plain fraction-based editors like the Ideogram-4 prompt builder, where a 0.3×0.3 box silently becomes a wide rectangle when you switch 1:1 to 16:9. The conversion is reversible - 1:1 → 16:9 → 1:1 lands exactly back where you started.

    The layout input is JSON (written by the editor, hidden in the UI) but you can paste a saved layout in by hand. global_prompt follows the same rule as everywhere in this suite: scene only, no people, or you get extra faces drawn in empty space.

    Getting it running

    Same install as the whole 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 - this suite only needs numpy. You'll still want the Krea 2 model files (Turbo or RAW transformer, Qwen3-VL encoder, Qwen-Image VAE) in place before you press Queue.

    Wire regions + loras + global_prompt + width + height straight into K2 Compose, and you're one K2 Regional Sampler away from a two-character image with no crop compositing. If your boxes land wrong, run K2 Region Preview first - a bad layout is much cheaper to spot there than in a full render.

    CategoryFVM Tools/K2

    Inputs (4)

    NameTypeDefaultDescription
    widthINT102464–16384Output width. Changing it rescales the layout shape-preserving instead of distorting the boxes.
    heightINT102464–16384Output height. Same shape-preserving rescale applies.
    global_promptSTRINGScene ONLY — no people. Describe the subjects in their boxes instead. Image tokens outside every region see only this text, so any person mentioned here gets drawn there. Measured with two regions: 'a sunlit park lawn with tall trees' → 2 faces, 'photo of a woman standing in a sunlit park' → 3, 'group portrait photo' → 5. Even the singular adds one too many.
    layoutSTRING{ "version": 1, "canvas": { "width": 1024, "height": 1024 }, "boxes": [] }Layout JSON written by the editor window. The frontend hides this widget; you can still edit it by hand or paste a saved layout.

    Outputs (6)

    NameTypeDescription
    regionsK2_REGION
    lorasK2_LORA
    global_promptSTRING
    widthINT
    heightINT
    reportSTRING