For the complete documentation index, see llms.txt. This page is also available as Markdown.

Grounding DINO

Dedicated Deployment या self-hosted Inference पर text-prompted object detection के लिए Grounding DINO का उपयोग करें

Grounding DINO एक open-vocabulary object detector है। आप एक image और text classes की एक सूची देते हैं, और model बिना किसी training के matching regions के लिए bounding boxes लौटाता है।

Grounding DINO Serverless Hosted API पर उपलब्ध नहीं है। इसे एक पर चलाएँ Dedicated Deployment या self-hosted Inference.

कोड नमूना

1

अपनी API Key प्राप्त करें

एक Roboflow खाता बनाएं, अपनी key यहाँ पर ढूँढें Roboflow API settings page और इसे अपने shell में उपलब्ध कराएँ:

export ROBOFLOW_API_KEY="your-key-here"
2

निर्भरताएँ इंस्टॉल करें

ये packages API को call करते हैं और इसके results को draw करते हैं:

pip install requests supervision opencv-python
3

मॉडल चलाएँ

सेट करें URL को अपने Dedicated Deployment URL या local Inference server पर।

import base64
import os
import cv2
import numpy as np
import requests
import supervision as sv

URL = "https://your-deployment.roboflow.cloud"
content = requests.get("https://media.roboflow.com/notebooks/examples/dog.jpeg").content
image = cv2.imdecode(np.frombuffer(content, np.uint8), cv2.IMREAD_COLOR)
_, buffer = cv2.imencode(".jpg", image)
image_base64 = base64.b64encode(buffer).decode("utf-8")

response = requests.post(
    f"{URL}/grounding_dino/infer",
    json={
        "api_key": os.environ["ROBOFLOW_API_KEY"],
        "image": {"type": "base64", "value": image_base64},
        "text": ["कुत्ता", "व्यक्ति", "बैकपैक"],
    },
)
preds = response.json()["predictions"]

xyxys = [
    [p["x"] - p["width"] / 2, p["y"] - p["height"] / 2,
     p["x"] + p["width"] / 2, p["y"] + p["height"] / 2]
    for p in preds
]
detections = sv.Detections(
    xyxy=np.array(xyxys, dtype=float),
    class_id=np.array([p.get("class_id", 0) for p in preds]),
    confidence=np.array([p["confidence"] for p in preds], dtype=float),
    data={"class_name": np.array([p["class"] for p in preds])},
)
labels = [f"{p['class']} {p['confidence']:.2f}" for p in preds]
annotated = sv.BoxAnnotator().annotate(image.copy(), detections)
annotated = sv.LabelAnnotator().annotate(annotated, detections, labels=labels)
cv2.imwrite("dog_annotated.png", annotated)

Inference speed

Latency मापी गई Roboflow Inference 1x NVIDIA L4 पर, batch size 1, warmup के बाद का औसत।

मॉडल
विलंबता (ms)

grounding-dino

165.4

दो text prompts के साथ मापा गया।

सेट करें URL को अपने deployment target से मिलाएँ:

अंतिम अपडेट

क्या यह उपयोगी था?