ComfyUI Node

SelectBboxes

Pick specific boxes out of a Bbox list by index

By lldacing·Created 3 years ago·Updated 8 months ago· 96
SelectBboxes
  • bboxes
  • bboxes
index0
bboxes_json

Run a face detector or a SAM segmentation node over an image and you don't get one bounding box back - you get a list. Ten faces, five detected objects, however many the model found. Most of the time you don't want all of them fed into whatever comes next (a crop-and-inpaint step, a mask-and-blur step); you want the second one, or the first and the fourth, or just whichever one is the biggest. SelectBboxes is the filter that sits between "here's everything I found" and "here's what I actually want to work on."

It comes out of lldacing's comfyui-easyapi-nodes, a pack built less for hand-tweaking a workflow in the UI and more for people wiring ComfyUI up behind an API - the whole pack leans automation-friendly, and this node is a good example of the pattern: it takes a batch of results and lets you narrow it down programmatically, by index, instead of eyeballing a preview and manually deleting nodes.

How it works

The mechanism is dead simple: it takes a list of Bbox entries and an index string, and returns only the entries at those positions. The index field is a plain string, not a number widget - that's deliberate, because it supports comma-separated values. Type 0 to keep just the first box, or 0,2,4 to keep the first, third, and fifth. Under the hood it's a Python-list-style positional filter: no fuzzy matching, no sorting by size or confidence, purely "give me these slots."

There's a sibling node in the same pack, SelectBbox (no trailing "es"), which does the same job but returns a single box instead of a list. Reach for SelectBboxes whenever you might want more than one - even if that's "one, for now" - so you can widen the index string later without swapping nodes.

Inputs and outputs that matter

  • index (required, string, default "0") - the position(s) to keep, comma-separated. This is the only field you'll actually type into.
  • bboxes (optional, BBOX) - the typed list wired in from an upstream detector: this pack's own SamAutoMaskSEGS/SamAutoMaskSEGSAdvanced, an Impact-Pack detector provider, InsightFaceBBOXDetect, or anything else on the graph that emits the BBOX type.
  • bboxes_json (optional, string) - the same data as a raw JSON string instead of a graph connection. This is the pack's API-friendliness showing through: if you're calling ComfyUI's API and don't have (or don't want) an actual detector node in the graph - say you already ran detection somewhere else and just want to post-process the coordinates - you can inject them as a JSON string parameter instead of building a fake upstream node.

You only need to wire one of bboxes or bboxes_json, not both. The single output, bboxes (BBOX), feeds straight into whatever expects a box list downstream - CropImageByBbox, MaskByBboxes, or another SelectBboxes/SelectBbox if you're chaining filters.

Installing it

Through ComfyUI Manager, search for comfyui-easyapi-nodes and install. By hand:

cd ComfyUI/custom_nodes
git clone https://github.com/lldacing/comfyui-easyapi-nodes.git
cd comfyui-easyapi-nodes
pip install -r requirements.txt

Restart ComfyUI. SelectBboxes itself is pure Python list-filtering - no model weights, no GPU work - but the README does ask for pip install -r requirements.txt because other nodes in the same pack (the SAM and InsightFace detectors) pull in heavier dependencies, and it's one shared install step for the whole pack.

Where people get tripped up

Because index is a string field, it's easy to fat-finger - a stray space ("0, 2") or a trailing comma can behave differently than you expect depending on how strictly the parser trims it, so if a box you asked for silently doesn't show up, check the exact string before assuming the upstream detector missed it. And since indexing is purely positional, it's tied to whatever order the upstream node emitted its boxes in - if that detector doesn't guarantee a stable order (some don't, especially across runs with slightly different confidence scores), "index 0" one run might not be the same face as "index 0" the next. If you need a specific object rather than a specific slot, filter on something else upstream (size, confidence, position) before this node, and only rely on SelectBboxes once the ordering is something you actually trust.

CategoryEasyApi/Bbox

Inputs (3)

NameTypeDefaultDescription
indexSTRING0
bboxesoptBBOX
bboxes_jsonoptSTRING

Outputs (1)

NameTypeDescription
bboxesBBOX