加载 GroundingDINO 模型
Load GroundingDINO by Name, Weights Land in models/grounding-dino
- grounding_dino_model
GroundingDINO is the "find it by name" detector: you give it a phrase like "bottle" or "product" and it returns bounding boxes for every matching instance in the image, zero-shot. KSSAMModelLoader is the SAM side; this node is its counterpart - KSGroundingDinoModelLoader loads the detection model that the rest of the Kongshan segmentation pipeline runs on.
The two choices
The dropdown has exactly two entries, and the difference is speed vs. accuracy:
GroundingDINO_SwinT_OGC(694MB) - the smaller Swin-T backbone. Faster, lighter, the sensible default for product shots where your subject is usually one big thing in the frame.GroundingDINO_SwinB(938MB) - the bigger Swin-B backbone. Better on small or cluttered scenes, slower, heavier.
Honest take: for "find the product in a catalog photo," SwinT is almost always enough - your subject is centered and occupies most of the frame, which is GroundingDINO's comfort zone. Go SwinB when you're detecting many small objects in a busy scene and the SwinT results start dropping boxes.
How it loads
The model files auto-download into ComfyUI/models/grounding-dino/ on first selection - both a .pth weight file and a .cfg.py config file come down together. The text encoder is bert-base-uncased: if you already have a bert-base-uncased folder under ComfyUI's models/ (many packs drop one there), it uses it; otherwise it falls back to downloading BERT from HuggingFace. So the real disk footprint of "one GroundingDINO" is 694MB–938MB of detector plus ~440MB of BERT unless you already have it. The model loads onto ComfyUI's current torch device and returns a GROUNDING_DINO_MODEL that feeds KSGroundingDinoDetect or the combined KSGroundedSAMSegment node.
Installation is the standard pack story:
cd ComfyUI/custom_nodes
git clone https://github.com/kongshan4219/ComfyUI-Kongshan-Nodes
restart ComfyUI. The transformers dependency (pulled by the pack) is what makes the BERT text encoder work.
Gotchas
- First load is a download, and a big one. 694MB minimum, plus BERT if you don't have it. Budget for it; the loader gives no progress percentage, just a "downloading..." log line.
- The output type is pack-private (
GROUNDING_DINO_MODEL), so it only connects to this pack's detector nodes. Same story as the SAM loader - every pack wires its own GroundingDINO, and they don't interoperate. - It's the same code GroundingDINO has shipped for years. This pack bundles a vendored copy of the model code (
local_groundingdino) rather than depending on the original repo, which is why it works out of the box but won't pick up upstream fixes. You're getting the classic pipeline as it was in ~2023-2024.
The KB's masking-detection-detailing essay describes the pattern this feeds: detect with GroundingDINO, mask with SAM, then optionally re-render or crop. This loader is the unglamorous first step - pick a size, wait for the download, wire the GROUNDING_DINO_MODEL into the detector. It's unremarkable in the best way: it just works.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| model_name | COMBO | GroundingDINO 模型版本。SwinB 通常更强但更大更慢;SwinT 体积较小、速度更快。 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| grounding_dino_model | GROUNDING_DINO_MODEL | — |