Bbox_strToBbox
Parse a text coordinate (hand-drawn or AI-generated) into a real bounding box
- image
- bbox
- normalized_str
- mask
- bbox_list
- normalized_list
- mask_list
This is the node that makes "point a vision-language model at your image and let it hand you a mask" actually work in Apt_Preset. Bbox_strToBbox takes a coordinate string - hand-drawn or spat out by an AI - and turns it into a real BOUNDING_BOX plus a MASK, so anything downstream that expects an actual box (an inpaint sampler, a crop node) gets one.
What it's for, and why two string formats
The node's own description (straight from the pack, translated) spells out exactly what it's handling:
normalized_str- a bounding-box string using normalized coordinates, meant for hand-drawn boxes.permil_str- a bounding-box string using per-mille (parts-per-thousand) coordinates, meant for AI-generated boxes.
That distinction matters more than it looks. Vision-language models that emit bounding boxes tend to output integer-ish coordinates on a fixed scale rather than clean 0–1 floats, and per-mille (0–1000) is a common choice for that - it avoids the model having to produce decimals. This node accepts either format depending on which string port you feed, and it's the counterpart to Bbox_BboxToStr, which exports a box the other way (as a normalized string). Together they're the plumbing for the modern "ground it with a VLM, derive the mask from the bbox" inpainting pattern: ask a model to locate an object in words, get coordinates back as text, convert to a usable mask here, and inpaint that region - no manual mask-painting required.
Inputs and outputs that matter
image(required) - the image the coordinates apply to. The string is meaningless without knowing what it's normalized against.index(default 0, min -1) - which box to extract when the string encodes more than one. Per the node's own description: 1 is the first box, 2 the second, and so on; -1 grabs the last box; 0 returns all of them.normalized_str/permil_str(optional strings) - feed whichever format your source produces. Leave the other blank.
Outputs give you both a single result and a list version, which is worth knowing before you wire this up:
bbox/normalized_str/mask- the single box (governed byindex), its normalized-string form, and its mask.bbox_list/normalized_list/mask_list- every box the string contained, as lists. Setindex=0and use these outputs if you actually want all detected regions, not just one.
Installing it
Via ComfyUI Manager: search ComfyUI-Apt_Preset, install, restart. Manual install:
cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git
then install.bat on Windows for dependencies, restart ComfyUI. No models involved - this is string parsing and coordinate math, nothing heavier.
Common issues
One box comes out when you expected several, or vice versa. This is almost always index. Leave it at the default (0) if your string might describe multiple objects and you want the list outputs; set it to a specific number only once you know exactly which box you want.
The mask is in the wrong spot. Format mismatch is the usual cause - feeding a per-mille string into normalized_str (or the reverse) will misinterpret the scale and place the box wrong. Match the string format to which port it came from: hand-drawn boxes go in normalized_str, model-generated coordinates go in permil_str.
The VLM's box is tighter than the actual object. This isn't specific to this node, but it's the standard trap in text-grounded masking workflows: grounding boxes from vision-language models tend to hug the object closely and clip parts a human would include (a cup's handle, a garment's edge). Pad the resulting box or mask before you inpaint with it, rather than trusting the raw coordinates - the model's box is a starting point, not a final mask.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| index | INT | 0 | — |
| normalized_stropt | STRING | — | |
| permil_stropt | STRING | — |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| bbox | BOUNDING_BOX | — |
| normalized_str | STRING | — |
| mask | MASK | — |
| bbox_list | BOUNDING_BOX | — |
| normalized_list | STRING | — |
| mask_list | MASK | — |