Nodes/ComfyUI-AusBoss/Layout Boxes πŸ†Ž
ComfyUI Node

Layout Boxes πŸ†Ž

Stop writing 'cat on the left' β€” draw the box instead with Layout Boxes

By ausbossΒ·Created 3 months agoΒ·Updated a day agoΒ· 68
Layout Boxes πŸ†Ž
  • background
  • bboxes
  • preview
  • bboxes
  • elements
  • mask
β—„width1024β–Ί
β—„height1024β–Ί
β—„layout{"v": 1, "boxes": []}β–Ί

What this is for

Prompting is a bad layout tool. You write "a red bicycle leaning on a brick wall, a sign in the top right", roll six times, and the sign ends up bottom left in four of them. You are describing composition in a language that has no coordinates.

Layout Boxes is the fix for models that accept coordinates. It gives you a canvas, you drag out rectangles, and you tell each one what belongs there: an object with a description, or text with actual words to render into the picture. The elements output carries that layout into the prompt encoder. It's the same idea the closed models sell as a feature - Ideogram 4 was trained on boxes and palettes in the caption schema, which is why Kijai's prompt builder exists to draw them - and what the regional prompting family has approximated for years. Boxes are a more honest interface than "on the left".

To be clear: the boxes are guidance, not a compositor. The model puts the thing roughly where you drew it.

How it works

Boxes live on the node as fractions of the canvas, in a hidden layout string, so resizing doesn't scramble your arrangement - a box at 25% across stays 25% across. The canvas is a JS panel the pack ships itself, which is why it works in the classic node look and not just Nodes 2.0, and everything it does lands in ordinary widget values, so save, load, undo and the API behave. At run time the helpers turn those fractions into three shapes: pixel boxes, prompt elements on a 0–1000 grid, and a mask.

The inputs that matter

  • width / height - canvas size, 1024Γ—1024 by default in 16px steps. Wire these from Latent Size so the boxes and your latent are the same shape; get it wrong and the layout lands somewhere else.
  • background - a picture to draw on top of. It shows under the boxes and takes over the canvas size, so the boxes are drawn on the picture at its own resolution. That's the mode you want for "fix the words on this photo".
  • bboxes - boxes in on a wire: bounding boxes, prompt elements from another node, or either as JSON text. New boxes fill the canvas; your manual edits then survive until the wire changes.
  • layout - the saved box text. Leave it alone unless you're scripting; it's for save/load and the API.

The outputs

preview shows the boxes with their numbers and words - wire it to Preview Image while you build. bboxes is the boxes in canvas pixels. elements is the one you came for: {type, bbox, text, desc, color_palette} per box, on a 0–1000 grid, ready for MOSS-Image Layout Prompt. mask is white inside every box - the sneaky fourth output the pack adds, which core's Create Bounding Boxes doesn't have.

If you already use Create Bounding Boxes, this is a drop-in: same inputs, same outputs in the same order. Worth noting, because Create Bounding Boxes only shows up in Nodes 2.0.

Install

Through ComfyUI Manager, search AusBoss and install it, or:

cd ComfyUI/custom_nodes
git clone https://github.com/ausboss/ComfyUI-AusBoss.git

Restart, then search the node library for AusBoss. No model downloads: it needs only the Pillow, NumPy and Torch ComfyUI already ships, and the pack's pyproject.toml declares zero dependencies. The pack wants ComfyUI 0.27.1+, and MOSS-Image needs a core that supports it - updating this pack can't add a model to ComfyUI.

Where people get stuck

Boxes snap and won't go where you want. Grid snapping is on for an empty canvas. Hold Ctrl (or Alt) while dragging to place freely, or set 8/16/32/64 in the gear. Over a background picture the grid is off by default, precisely so boxes can sit anywhere.

The canvas shows the wrong size. Before a run it can only read a wired size from a node it understands - Latent Size, Integer, a Primitive. From anything else it keeps its own size until the run happens. Not a bug, but it makes you doubt your eyes.

Mask edges leave a faint line when you inpaint. mask has hard edges. Draw the box ~12px wider than the old letters, then soften with Mask Refine at a blur around 6 before Set Latent Noise Mask. A box that clips a letter leaves half a letter.

Turned boxes disagree with other nodes. A box can be angled for lettering on a slant, and mask follows the turn exactly - but bboxes and elements only speak straight rectangles, so they get the straight box around it. A turned text box does tell the model its slant in the description, which is more than most packs bother with.

CategoryπŸ†Ž AusBoss/Utility

Inputs (5)

NameTypeDefaultDescription
backgroundoptIMAGEA picture to draw the boxes on (optional). It shows under the boxes, and its size becomes the canvas size.
bboxesoptBOUNDING_BOX,ARRAY,STRINGBoxes to start from (optional): bounding boxes, prompt elements, or either as JSON text. When the wire brings new boxes they fill the canvas; changes you make on the canvas then stay until the boxes on the wire change.
widthoptINT102464–16384Canvas width in pixels: the width of the picture you make. Wire it from Latent Size to keep the two the same.
heightoptINT102464–16384Canvas height in pixels: the height of the picture you make. Wire it from Latent Size to keep the two the same.
layoutoptSTRING{"v": 1, "boxes": []}The boxes, drawn on the node and saved here as text: where each box is (as parts of the canvas), how far it is turned, its type, its words and its colors.

Outputs (4)

NameTypeDescription
previewIMAGEA picture of the boxes with their numbers and words, to check the layout. Wire it to Preview Image.
bboxesBOUNDING_BOXThe boxes in pixels of the canvas (x, y, width, height), for nodes that take bounding boxes. A turned box gives the straight box around it.
elementsARRAYThe boxes as prompt elements: type, place, words and colors. Wire it to MOSS-Image Layout Prompt. A turned text box says its slant in its description.
maskMASKThe boxes as a mask: white inside every box, turned boxes as they are turned. Use it to change only those places of a picture, such as the words on a sign.