Skip to content

Detect Objects Using Grounding DINO

SUMMARY

Detect Objects Using Grounding DINO detects objects using Grounding DINO and returns detections with bounding boxes and categories built from a list of object names you supply.

This Skill is designed for open-vocabulary, zero-shot object detection where you name the objects you want to find (for example, ["carton", "pallet"]) instead of picking from a fixed set of class IDs.

Use this Skill when you want to detect objects you can name in words, without retraining a model.

The Skill

python
from telekinesis import retina

detection_results, categories = retina.detect_objects_using_grounding_dino(
    image=image,
    objects=["carton"],
    box_threshold=0.5,
    text_threshold=0.5,
)
API Reference
Full parameter and return type documentation for detect_objects_using_grounding_dino.
View Reference →

Example

Input Image

Input

Original image

Detected Objects

Output image

Detected objects with bounding boxes, labels and scores from a list of object names.

The Code

python
"""
Detect objects using Grounding DINO (zero-shot).
"""

from loguru import logger
import rerun as rr

from telekinesis import retina, datatypes


def detect_objects_using_grounding_dino_example():
    """
    Detect objects using Grounding DINO (zero-shot).

    Requires the input objects to be defined to detect objects in an image and
    returns object detections using datatype `COCOObjectDetectionDetectionResults` with `Categories`.
    """
    # ===================== Load Image ==========================================
    image_url = "https://assets.telekinesis.ai/examples/v1/images/palletizing.jpg"
    image = datatypes.Image.from_url(url=image_url)

    # ===================== Run Skill ==========================================
    detection_results, categories = retina.detect_objects_using_grounding_dino(
        image=image,
        objects=["carton"],
        box_threshold=0.45,
        text_threshold=0.5,
    )

    # ===================== Log ================================================
    logger.success(f"Detected objects in {image} using Grounding DINO (zero-shot).")
    logger.success(f"Results: {detection_results}")

    logger.info(f"Categories available: {categories}")
    logger.info(f"All detected object bounding boxes: {detection_results.bboxes}")
    logger.info(f"All detected object scores: {detection_results.scores}")
    logger.info(f"All detected object category IDs: {detection_results.category_ids}")

    # Indexed object is of type `COCOObjectDetectionResult`
    logger.info(f"Detected object at index 0: {detection_results[0]}")
    logger.info(f"Detected object at index 0 bounding box: {detection_results[0].bbox}")
    logger.info(f"Detected object at index 0 score: {detection_results[0].score}")
    logger.info(
        f"Detected object at index 0 category ID: {detection_results[0].category_id}"
    )
    logger.info(
        f"Detected object at index 0 category name: {categories[detection_results[0].category_id]}"
    )

    # ===================== Visualization  (Optional) ======================
    rr.init("detect_objects_using_grounding_dino_example", spawn=True)
    datatypes.visualize(image, entity_path="/image/")
    datatypes.visualize(detection_results, entity_path="/image/overlayed_detections")


if __name__ == "__main__":
    detect_objects_using_grounding_dino_example()

Runnable examples are available in the Telekinesis examples repository.

Follow the README in that repository to set up the environment, run this specific example with:

bash
cd telekinesis-examples
python examples/detection/detect_objects_using_grounding_dino.py

Parameter Configuration

These parameters are passed directly to the underlying Grounding DINO model and control which objects it looks for and how confident it must be before reporting a detection.

KeyTypeDefaultDescription
imagedatatypes.Image | np.ndarray | listrequiredInput image. Supported shapes are (H, W), (H, W, 1), or (H, W, 3) — 4-channel (alpha) images are not supported
objectslist[datatypes.String | str]requiredList of object names to detect (for example, ["carton", "pallet"]). Internally joined into a single comma-separated string sent to the model — avoid commas inside an individual object name
box_thresholddatatypes.Float | float | int0.25Minimum confidence required for a predicted bounding box
text_thresholddatatypes.Float | float | int0.25Minimum confidence required for matching an image region to an object name

Returns

TypeDescription
tuple[datatypes.COCOObjectDetectionResults, datatypes.Categories]A (detections, categories) pair. detections holds the COCO-style results — access the grouped arrays via .bboxes (shape (N, 4), [x, y, w, h]), .scores (shape (N,)), and .category_ids (shape (N,)), or index a single detection with detections[i] to get its .bbox, .score, and .category_id. categories holds the object names you supplied — index it by category id (e.g. categories[detections[0].category_id]) to get a Category with a .name.

Raises

ExceptionCondition
TypeErrorA parameter's value does not match its expected type (see the Parameter Configuration table above)
ValueErrorimage has an unsupported shape, objects is empty or contains an empty/whitespace-only string, or box_threshold/text_threshold is outside the valid 0.01.0 range
ConfigurationErrorThe TELEKINESIS_API_KEY environment variable is not set
SerializationErrorThe request input failed to serialize, or the response failed to deserialize
RequestTimeoutErrorThe request to the Retina service timed out
TransportErrorA network failure occurred before a response was received
ClientErrorThe Retina service rejected the request due to invalid input, invalid data, or another unexpected 4xx response
AuthenticationErrorThe API key was rejected as invalid or expired
AuthenticationServiceErrorThe authentication service was unavailable
ServerErrorThe Retina service returned a 5xx or otherwise unexpected error response

How to Tune the Parameters

The detect_objects_using_grounding_dino Skill exposes one required list and two confidence thresholds.

objects

  • Controls: Which object names the model searches the image for.
  • Use specific, singular nouns ("carton" rather than "cartons and boxes") — one concept per entry
  • Add more entries to search for several object types in a single call (e.g. ["carton", "pallet", "forklift"])
  • Reword an entry if it's returning too many or too few matches — Grounding DINO matches on the literal wording

box_threshold

  • Controls: The minimum confidence required for a predicted bounding box to be kept.
  • Default: 0.25
  • Increase → fewer, higher-confidence boxes (reduces false positives)
  • Decrease → more boxes kept, including lower-confidence ones (improves recall for hard or small objects)
  • Typical range: 0.30.7

text_threshold

  • Controls: The minimum confidence required for matching an image region to one of the objects names.
  • Default: 0.25
  • Increase → stricter text-to-region matching
  • Decrease → looser matching, useful when valid detections are being missed
  • Typical range: 0.20.7

TIP

Best practice: Start with box_threshold=0.5 and text_threshold=0.5 — higher than the library defaults of 0.25/0.25 — then loosen either one if valid detections are being missed, or tighten if you see false positives.

Where to Use the Skill

Common pipelines include:

  • Open-vocabulary inspection – Detecting user-defined object types without retraining
  • Flexible warehouse analytics – Rapidly switching targets by changing the objects list (for example, cartons, pallets, forklifts)

Alternative Skills

Skillvs. Detect Objects Using Grounding DINO
detect_objects_using_qwenQWEN is a general VLM with no tunable thresholds. Use Grounding DINO when you want finer control over the box/text confidence trade-off; use QWEN for a simpler call.
detect_objects_using_yoloxUse YOLOX when you need faster inference on a fixed set of categories.

When Not to Use the Skill

Do not use Detect Objects Using Grounding DINO when:

  • You only need fixed-category detection with strict real-time latency (YOLOX is usually faster)
  • Wording sensitivity is not acceptable in the workflow (results depend on how object names are phrased)
  • The target classes are fully known and stable (a fixed detector may be simpler to operate)