GroundingDINO 检测框
Find 'the Product' by Name and Get Its Bounding Boxes
- grounding_dino_model
- image
- boxes
- box_count
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_BOXESoutput 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 == 0means you're wired wrong or the prompt is wrong. If detection finds nothing, first try a broader prompt (productinstead ofred 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.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| grounding_dino_model | GROUNDING_DINO_MODEL | 已加载的 GroundingDINO 模型。 | |
| image | IMAGE | 待检测图片批次。每张图都会按相同 prompt 检测目标框。 | |
| prompt | STRING | 检测目标文本,例如 product、bottle、shoe。越具体越少误检,但过窄可能漏检。 | |
| threshold | FLOAT | 0.300–1 | 检测置信度阈值。降低会找到更多框但误检增加;提高会更严格但可能漏掉目标。 |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| boxes | KS_DINO_BOXES | — |
| box_count | INT | — |