Grounding DINO (Roboflow Fork)
raw JSON → 0.3.0 verified Sat May 09 auth: no python
A Roboflow-maintained fork of Grounding DINO, a state-of-the-art open-set object detector that can detect arbitrary objects based on text prompts. Version 0.3.0 combines image and text encoders with a transformer-based fusion approach. Release cadence is irregular; actively maintained.
pip install rf-groundingdino Common errors
error ModuleNotFoundError: No module named 'groundingdino' ↓
cause Package name changed to rf_groundingdino.
fix
Install rf-groundingdino and use 'from rf_groundingdino import groundingdino'.
error AssertionError: The two points are of different shapes ↓
cause Common when using predict() with wrong prompt format (e.g., missing spaces around '.').
fix
Ensure prompts are formatted as 'class1 . class2 . class3' with spaces around dots.
Warnings
breaking Package renamed from 'groundingdino' to 'rf_groundingdino' in v0.1.2. All imports must use 'rf_groundingdino' prefix. ↓
fix Change imports: 'import groundingdino' -> 'from rf_groundingdino import groundingdino'
gotcha The predict() function expects prompts in a specific format: separate each class with ' . ' (space-dot-space). Omitting spaces or using different separators leads to zero detections. ↓
fix Use format: 'cat . dog . person' (note the spaces around the dot).
gotcha Model weights are not included in pip install. You must download them manually from the GitHub releases page. ↓
fix Download weights from https://github.com/roboflow/GroundingDINO/releases and provide the path.
deprecated The old 'groundingdino' package (v0.1.0) is unmaintained and incompatible with this fork. ↓
fix Uninstall old package and install rf-groundingdino: pip install rf-groundingdino
Imports
- groundingdino wrong
import groundingdinocorrectfrom rf_groundingdino import groundingdino - load_model wrong
from groundingdino.util.inference import load_modelcorrectfrom rf_groundingdino.util.inference import load_model - predict wrong
from groundingdino.util.inference import predictcorrectfrom rf_groundingdino.util.inference import predict
Quickstart
from rf_groundingdino import groundingdino
from rf_groundingdino.util.inference import load_model, predict
import torch
device = 'cuda' if torch.cuda.is_available() else 'cpu'
model = load_model('groundingdino_swint_ogc', 'path/to/config.py', 'path/to/weights.pth')
# For inference, use predict() or model()
import cv2
image = cv2.imread('image.jpg')
prompts = 'cat . dog .' # separate classes with ' . '
boxes, logits, phrases = predict(model, image, prompts, box_threshold=0.3, text_threshold=0.25)
print('Detections:', len(phrases))