Grounding DINO
Dedicated Deployment या self-hosted Inference पर टेक्स्ट-प्रॉम्प्टेड ऑब्जेक्ट डिटेक्शन के लिए Grounding DINO का उपयोग करें
कोड नमूना
3
मॉडल चलाएँ
import base64
import os
import cv2
import numpy as np
import requests
import supervision as sv
URL = "https://your-deployment.roboflow.cloud"
image = sv.load_image_from_url("https://media.roboflow.com/notebooks/examples/dog.jpeg")
_, 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)
इन्फरेंस गति
मॉडल
विलंबता (ms)
Inference के साथ उपयोग करें (सेल्फ-होस्टेड)
2
मॉडल चलाएँ
from inference.models.grounding_dino import GroundingDINO
model = GroundingDINO(api_key="YOUR_API_KEY")
results = model.infer(
{
"image": {
"type": "url",
"value": "https://media.roboflow.com/fruit.png",
},
"text": ["सेब"],
# वैकल्पिक थ्रेशहोल्ड, दोनों का डिफ़ॉल्ट 0.5 है
"box_threshold": 0.5,
"text_threshold": 0.5,
}
)
print(results)अंतिम अपडेट
क्या यह उपयोगी था?