Nodes/Kongshan Nodes/GroundingDINO 检测框
ComfyUI Node

GroundingDINO 检测框

Find 'the Product' by Name and Get Its Bounding Boxes

By kongshan4219·Created 3 months ago·Updated 3 months ago· 0
GroundingDINO 检测框
  • grounding_dino_model
  • image
  • boxes
  • box_count
prompt
threshold0.30

You have a photo full of stuff and you need to find the product before you can cut it out or mask it. KSGroundingDinoDetect is the node that does the finding: it runs a loaded GroundingDINO model over your image with a text prompt like product, bottle, or shoe, and returns the bounding boxes it found - plus a count, so you can tell at a glance whether it saw anything at all.

How it works

This is the "detect" step of the classic detect-then-segment pipeline the KB's masking-detection-detailing essay walks through. GroundingDINO is a zero-shot open-vocabulary detector: no fine-tuning needed, you just describe what you're looking for in plain text. The node runs your image through the model once per frame, filters detections by a confidence threshold, and emits the surviving boxes.

The key input after the model is the prompt. The tooltip says it plainly: product leans toward finding the whole product; a more specific word narrows the range. This is where the real tuning happens. On a catalog photo, product or the actual object name (bag, vase, watch) is what you want. On a group shot, product may return several boxes - which is correct, because the downstream SAM step will cut out each one.

  • threshold (default 0.3) - confidence cutoff. Lower it and you get more boxes but more false positives; raise it and you get fewer, cleaner detections but risk missing a target. 0.3 is a decent starting point; if you're drowning in junk boxes, nudge to 0.4–0.5.

Outputs are boxes (type KS_DINO_BOXES - a list of per-image box arrays, in pixel coordinates scaled to your image size) and box_count (total across all frames; 0 means nothing passed the threshold).

The 1688-shaped context

Where does detection matter in the Kongshan pipeline? It's the entry to product cutting. Detect the product box → KSSAMSegmentByBoxes turns each box into a precise mask → KSProductsToBackground crops and centers each instance onto white. One photo, several products, each one becomes a clean listing image. That's a real Alibaba-seller workflow - and the reason this pack exists at all.

Installing

With the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/kongshan4219/ComfyUI-Kongshan-Nodes

restart ComfyUI. You need a loaded model from KSGroundingDinoModelLoader first - nothing runs without it.

Gotchas

  • Boxes are relative to the source image, one list per image. The KS_DINO_BOXES output is designed to plug straight into this pack's SAM node, not into arbitrary other packs. If you need raw x/y/w/h ints, this pack doesn't currently expose a splitter for them.
  • box_count == 0 means you're wired wrong or the prompt is wrong. If detection finds nothing, first try a broader prompt (product instead of red handbag), then check your threshold. GroundingDINO's vocabulary is broad but it's not magic - it matches object classes, not fine attributes.
  • It's slow-ish on first run per image. BERT text encoder + Swin backbone per frame; on a batch it adds up. Fine for a few product shots, not a real-time tool.

Young, tiny pack (zero impressions on every node as of now), and this is one of the workhorse local nodes - unglamorous, competent, and the natural entry point for everything downstream that wants to know where the product is.

CategoryKongshan/Local

Inputs (4)

NameTypeDefaultDescription
grounding_dino_modelGROUNDING_DINO_MODEL已加载的 GroundingDINO 模型。
imageIMAGE待检测图片批次。每张图都会按相同 prompt 检测目标框。
promptSTRING检测目标文本,例如 product、bottle、shoe。越具体越少误检,但过窄可能漏检。
thresholdFLOAT0.300–1检测置信度阈值。降低会找到更多框但误检增加;提高会更严格但可能漏掉目标。

Outputs (2)

NameTypeDescription
boxesKS_DINO_BOXES
box_countINT