> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-hi/vision-models/groundingdino.md).

# GroundingDINO

GroundingDINO के साथ पाठ विवरणों का उपयोग करके किसी भी वस्तु का पता लगाएँ।

{% hint style="success" %}
सभी उदाहरण GPU सर्वरों पर चलाए जा सकते हैं जिन्हें द्वारा किराए पर लिया गया है [CLORE.AI मार्केटप्लेस](https://clore.ai/marketplace).
{% endhint %}

{% hint style="info" %}
इस मार्गदर्शिका के सभी उदाहरणों को GPU सर्वरों पर चलाया जा सकता है जिन्हें के माध्यम से किराए पर लिया जाता है [CLORE.AI मार्केटप्लेस](https://clore.ai/marketplace) मार्केटप्लेस।
{% endhint %}

## CLORE.AI पर किराये पर लेना

1. पर जाएँ [CLORE.AI मार्केटप्लेस](https://clore.ai/marketplace)
2. GPU प्रकार, VRAM, और मूल्य के अनुसार फ़िल्टर करें
3. चुनें **ऑन-डिमांड** (निश्चित दर) या **स्पॉट** (बिड प्राइस)
4. अपना ऑर्डर कॉन्फ़िगर करें:
   * Docker इमेज चुनें
   * पोर्ट सेट करें (SSH के लिए TCP, वेब UI के लिए HTTP)
   * यदि आवश्यक हो तो एनवायरनमेंट वेरिएबल जोड़ें
   * स्टार्टअप कमांड दर्ज करें
5. भुगतान चुनें: **CLORE**, **BTC**, या **USDT/USDC**
6. ऑर्डर बनाएं और डिप्लॉयमेंट का इंतज़ार करें

### अपने सर्वर तक पहुँचें

* कनेक्शन विवरण में खोजें **मेरे ऑर्डर**
* वेब इंटरफेस: HTTP पोर्ट URL का उपयोग करें
* SSH: `ssh -p <port> root@<proxy-address>`

## GroundingDINO क्या है?

IDEA-Research द्वारा GroundingDINO सक्षम करता है:

* पाठ प्रॉम्प्ट के साथ शून्य-शॉट वस्तु पहचान
* प्रशिक्षण के बिना किसी भी वस्तु का पता लगाएँ
* उच्च-सटीकता बाउंडिंग बॉक्स लोकलाइज़ेशन
* स्वचालित सेगमेंटेशन के लिए SAM के साथ संयोजन

## संसाधन

* **GitHub:** [IDEA-Research/GroundingDINO](https://github.com/IDEA-Research/GroundingDINO)
* **पेपर:** [GroundingDINO पेपर](https://arxiv.org/abs/2303.05499)
* **HuggingFace:** [IDEA-Research/grounding-dino](https://huggingface.co/IDEA-Research/grounding-dino-base)
* **डेमो:** [HuggingFace Space](https://huggingface.co/spaces/IDEA-Research/Grounding_DINO_Demo)

## अनुशंसित हार्डवेयर

| घटक     | न्यूनतम       | अनुशंसित      | सर्वोत्तम     |
| ------- | ------------- | ------------- | ------------- |
| GPU     | RTX 3060 12GB | RTX 4080 16GB | RTX 4090 24GB |
| VRAM    | 6GB           | 12GB          | 16GB          |
| CPU     | 4 कोर         | 8 कोर         | 16 कोर        |
| RAM     | 16GB          | 32GB          | 64GB          |
| स्टोरेज | 20GB SSD      | 50GB NVMe     | 100GB NVMe    |
| इंटरनेट | 100 Mbps      | 500 Mbps      | 1 Gbps        |

## CLORE.AI पर त्वरित डिप्लॉय

**Docker इमेज:**

```
pytorch/pytorch:2.5.1-cuda12.4-cudnn9-devel
```

**पोर्ट:**

```
22/tcp
7860/http
```

**कमांड:**

```bash
cd /workspace && \
git clone https://github.com/IDEA-Research/GroundingDINO.git && \
cd GroundingDINO && \
pip install -e . && \
python demo/gradio_demo.py
```

## अपनी सेवा तक पहुँचना

डिप्लॉयमेंट के बाद, अपना खोजें `http_pub` URL में **मेरे ऑर्डर**:

1. जाएँ **मेरे ऑर्डर** पृष्ठ
2. अपने ऑर्डर पर क्लिक करें
3. खोजें `http_pub` URL (उदा., `abc123.clorecloud.net`)

उपयोग करें `https://YOUR_HTTP_PUB_URL` की बजाय `localhost` नीचे दिए उदाहरणों में।

## इंस्टॉलेशन

```bash
git clone https://github.com/IDEA-Research/GroundingDINO.git
cd GroundingDINO
pip install -e .

# वेट्स डाउनलोड करें
mkdir weights
cd weights
wget https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth
```

## आप क्या बना सकते हैं

### स्वचालित लेबलिंग

* एमएल प्रशिक्षण के लिए डेटासेट स्वचालित रूप से एनोटेट करें
* विवरणों से बाउंडिंग बॉक्स उत्पन्न करें
* डेटा लेबलिंग पाइपलाइनों को तेज करें

### विज़ुअल सर्च

* इमेज डेटाबेस में विशिष्ट वस्तुओं को खोजें
* कंटेंट मॉडरेशन सिस्टम
* रिटेल में उत्पाद की पहचान

### रोबोटिक्स और ऑटोमेशन

* रोबोट आर्म के लिए वस्तु स्थानिकरण
* इन्वेंटरी प्रबंधन प्रणाली
* गुणवत्ता नियंत्रण निरीक्षण

### रचनात्मक अनुप्रयोग

* फोटोज़ से विषयों को ऑटो-कॉर्प करें
* SAM के साथ वस्तु मास्क जेनरेट करें
* कंटेंट-अवेयर इमेज संपादन

### विश्लेषण

* छवियों में वस्तुओं की गणना करें
* फोटो से इन्वेंटरी ट्रैक करें
* वन्यजीव निगरानी

## मूल उपयोग

```python
from groundingdino.util.inference import load_model, load_image, predict, annotate
import cv2

# मॉडल लोड करें
model = load_model(
    "groundingdino/config/GroundingDINO_SwinT_OGC.py",
    "weights/groundingdino_swint_ogc.pth"
)

# छवि लोड करें
image_source, image = load_image("input.jpg")

# वस्तुओं का पता लगाएँ
TEXT_PROMPT = "cat . dog . person"
BOX_THRESHOLD = 0.35
TEXT_THRESHOLD = 0.25

boxes, logits, phrases = predict(
    model=model,
    image=image,
    caption=TEXT_PROMPT,
    box_threshold=BOX_THRESHOLD,
    text_threshold=TEXT_THRESHOLD
)

# छवि एनोटेट करें
annotated_frame = annotate(
    image_source=image_source,
    boxes=boxes,
    logits=logits,
    phrases=phrases
)

cv2.imwrite("output.jpg", annotated_frame)
```

## GroundingDINO + SAM (Grounded-SAM)

डिटेक्शन को सेगमेंटेशन के साथ जोड़ें:

```python
import torch
import numpy as np
from groundingdino.util.inference import load_model, load_image, predict
from segment_anything import sam_model_registry, SamPredictor

# GroundingDINO लोड करें
dino_model = load_model(
    "groundingdino/config/GroundingDINO_SwinT_OGC.py",
    "weights/groundingdino_swint_ogc.pth"
)

# SAM लोड करें
sam = sam_model_registry["vit_h"](checkpoint="sam_vit_h_4b8939.pth")
sam.to(device="cuda")
sam_predictor = SamPredictor(sam)

# छवि लोड करें
image_source, image = load_image("input.jpg")

# GroundingDINO के साथ डिटेक्ट करें
boxes, logits, phrases = predict(
    model=dino_model,
    image=image,
    caption="person . car",
    box_threshold=0.35,
    text_threshold=0.25
)

# SAM के साथ सेगमेंट करें
sam_predictor.set_image(image_source)

# बॉक्स को SAM फॉर्मेट में कन्वर्ट करें
H, W = image_source.shape[:2]
boxes_xyxy = boxes * torch.tensor([W, H, W, H])

masks = []
for box in boxes_xyxy:
    mask, _, _ = sam_predictor.predict(
        box=box.numpy(),
        multimask_output=False
    )
    masks.append(mask)
```

## बैच प्रोसेसिंग

```python
import os
from groundingdino.util.inference import load_model, load_image, predict, annotate
import cv2

model = load_model(
    "groundingdino/config/GroundingDINO_SwinT_OGC.py",
    "weights/groundingdino_swint_ogc.pth"
)

input_dir = "./images"
output_dir = "./detected"
os.makedirs(output_dir, exist_ok=True)

TEXT_PROMPT = "product . price tag . barcode"

for filename in os.listdir(input_dir):
    if not filename.endswith(('.jpg', '.png')):
        continue

    image_path = os.path.join(input_dir, filename)
    image_source, image = load_image(image_path)

    boxes, logits, phrases = predict(
        model=model,
        image=image,
        caption=TEXT_PROMPT,
        box_threshold=0.3,
        text_threshold=0.25
    )

    annotated = annotate(image_source, boxes, logits, phrases)
    cv2.imwrite(os.path.join(output_dir, filename), annotated)

    print(f"{filename}: Found {len(boxes)} objects")
```

## कस्टम डिटेक्शन पाइपलाइन

```python
from groundingdino.util.inference import load_model, load_image, predict
import json

model = load_model(
    "groundingdino/config/GroundingDINO_SwinT_OGC.py",
    "weights/groundingdino_swint_ogc.pth"
)

def detect_and_export(image_path, prompt, output_json):
    image_source, image = load_image(image_path)
    H, W = image_source.shape[:2]

    boxes, logits, phrases = predict(
        model=model,
        image=image,
        caption=prompt,
        box_threshold=0.35,
        text_threshold=0.25
    )

    # निरपेक्ष निर्देशाँक में कन्वर्ट करें
    detections = []
    for box, logit, phrase in zip(boxes, logits, phrases):
        x1, y1, x2, y2 = box * torch.tensor([W, H, W, H])
        detections.append({
            "label": phrase,
            "confidence": float(logit),
            "bbox": {
                "x1": int(x1),
                "y1": int(y1),
                "x2": int(x2),
                "y2": int(y2)
            }
        })

    with open(output_json, "w") as f:
        json.dump(detections, f, indent=2)

    return detections

# कारों और लोगों का पता लगाएँ
results = detect_and_export(
    "street.jpg",
    "car . person . bicycle . traffic light",
    "detections.json"
)
```

## Gradio इंटरफ़ेस

```python
import gradio as gr
import cv2
from groundingdino.util.inference import load_model, load_image, predict, annotate
import tempfile
import numpy as np

model = load_model(
    "groundingdino/config/GroundingDINO_SwinT_OGC.py",
    "weights/groundingdino_swint_ogc.pth"
)

def detect_objects(image, text_prompt, box_threshold, text_threshold):
    # अस्थायी छवि सहेजें
    with tempfile.NamedTemporaryFile(suffix=".jpg", delete=False) as f:
        cv2.imwrite(f.name, cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR))
        image_source, img = load_image(f.name)

    boxes, logits, phrases = predict(
        model=model,
        image=img,
        caption=text_prompt,
        box_threshold=box_threshold,
        text_threshold=text_threshold
    )

    annotated = annotate(image_source, boxes, logits, phrases)
    annotated_rgb = cv2.cvtColor(annotated, cv2.COLOR_BGR2RGB)

    return annotated_rgb, f"Found {len(boxes)} objects: {', '.join(phrases)}"

demo = gr.Interface(
    fn=detect_objects,
    inputs=[
        gr.Image(type="pil", label="इनपुट इमेज"),
        gr.Textbox(label="Objects to Detect", value="person . car . dog", placeholder="object1 . object2 . object3"),
        gr.Slider(0.1, 0.9, value=0.35, label="Box Threshold"),
        gr.Slider(0.1, 0.9, value=0.25, label="Text Threshold")
    ],
    outputs=[
        gr.Image(label="Detection Result"),
        gr.Textbox(label="Summary")
    ],
    title="GroundingDINO - Open-Set Object Detection",
    description="पाठ में वर्णन करके किसी भी वस्तु का पता लगाएँ। CLORE.AI GPU सर्वरों पर चल रहा है."
)

demo.launch(server_name="0.0.0.0", server_port=7860)
```

## प्रदर्शन

| कार्य           | रिज़ॉल्यूशन | GPU      | स्पीड |
| --------------- | ----------- | -------- | ----- |
| एकल छवि         | 800x600     | RTX 3090 | 120ms |
| एकल छवि         | 800x600     | RTX 4090 | 80ms  |
| एकल छवि         | 1920x1080   | RTX 4090 | 150ms |
| बैच (10 छवियाँ) | 800x600     | RTX 4090 | 600ms |

## सामान्य समस्याएँ और समाधान

### कम डिटेक्शन सटीकता

**समस्या:** वस्तुएँ पता नहीं लग रही हैं

**समाधान:**

* कम करें `box_threshold` 0.2-0.3 पर
* कम करें `text_threshold` 0.15-0.2 पर
* और अधिक विशिष्ट वस्तु विवरणों का उपयोग करें
* वस्तुओं को अल्पविराम के बजाय " . " से अलग करें

```python

# अच्छा प्रॉम्प्ट फॉर्मेट
TEXT_PROMPT = "red car . person wearing hat . wooden chair"

# बुरा प्रॉम्प्ट फॉर्मेट
TEXT_PROMPT = "red car, person wearing hat, wooden chair"
```

### आउट ऑफ़ मेमोरी

**समस्या:** बड़ी छवियों पर CUDA OOM

**समाधान:**

```python

# डिटेक्शन से पहले बड़ी छवियों का आकार बदलें
from PIL import Image

def resize_if_needed(image_path, max_size=1280):
    img = Image.open(image_path)
    if max(img.size) > max_size:
        ratio = max_size / max(img.size)
        new_size = (int(img.width * ratio), int(img.height * ratio))
        img = img.resize(new_size, Image.LANCZOS)
        img.save(image_path)
```

### धिमा इनफ़रेंस

**समस्या:** डिटेक्शन बहुत समय ले रहा है

**समाधान:**

* छोटे इनपुट छवियों का उपयोग करें
* कई छवियों को बैच में प्रोसेस करें
* FP16 इन्फरेंस का उपयोग करें
* तेज़ GPU किराये पर लें (RTX 4090, A100)

### गलत सकारात्मक (False Positives)

**समस्या:** गलत वस्तुओं का पता लगना

**समाधान:**

* बढ़ाएँ `box_threshold` 0.4-0.5 पर
* प्रॉम्प्ट में अधिक विशिष्ट रहें
* नकारात्मक प्रॉम्प्ट का उपयोग करें (डिटेक्शन के बाद परिणाम फ़िल्टर करें)

```python

# कम-विश्वास डिटेक्शनों को फ़िल्टर करें
filtered = [(b, l, p) for b, l, p in zip(boxes, logits, phrases) if l > 0.5]
```

## समस्याओं का निवारण

### ऑब्जेक्ट्स डिटेक्ट नहीं हो रहे हैं

* अधिक विशिष्ट पाठ विवरणों का उपयोग करें
* विभिन्न वाक्य-विन्यास आज़माएँ
* कॉन्फिडेंस थ्रेशोल्ड कम करें

### बाउंडिंग बॉक्स गलत हैं

* पाठ प्रॉम्प्ट में अधिक विशिष्ट रहें
* कई वस्तुओं को अलग करने के लिए "." का उपयोग करें
* छवि गुणवत्ता जांचें

{% hint style="danger" %}
**मेमोरी खत्म**
{% endhint %}

* छवि रिज़ॉल्यूशन कम करें
* छवियों को एक-एक करके प्रोसेस करें
* छोटे मॉडल वेरिएंट का उपयोग करें

### धीमी निष्पादन गति

* गति के लिए TensorRT का उपयोग करें
* समान आकार की छवियों को बैच में प्रोसेस करें
* FP16 इन्फरेंस सक्षम करें

## लागत अनुमान

सामान्य CLORE.AI मार्केटप्लेस दरें (2024 के अनुसार):

| GPU       | घंटात्मक दर | दैनिक दर | 4-घंटे सत्र |
| --------- | ----------- | -------- | ----------- |
| RTX 3060  | \~$0.03     | \~$0.70  | \~$0.12     |
| RTX 3090  | \~$0.06     | \~$1.50  | \~$0.25     |
| RTX 4090  | \~$0.10     | \~$2.30  | \~$0.40     |
| A100 40GB | \~$0.17     | \~$4.00  | \~$0.70     |
| A100 80GB | \~$0.25     | \~$6.00  | \~$1.00     |

*कीमतें प्रदाता और मांग के अनुसार बदलती हैं। जाँच करें* [*CLORE.AI मार्केटप्लेस*](https://clore.ai/marketplace) *वर्तमान दरों के लिए।*

**पैसे बचाएँ:**

* उपयोग करें **स्पॉट** लचीले वर्कलोड के लिए मार्केट (अक्सर 30-50% सस्ता)
* भुगतान करें **CLORE** टोकन के साथ
* विभिन्न प्रदाताओं के बीच कीमतों की तुलना करें

## अगले कदम

* [SAM2](/guides/guides_v2-hi/vision-models/sam2-video.md) - डिटेक्ट किए गए ऑब्जेक्ट्स का सेगमेंट
* [Florence-2](/guides/guides_v2-hi/vision-models/florence2.md) - और अधिक विज़न कार्य
* [YOLO](/guides/guides_v2-hi/computer-vision/yolov8-detection.md) - ज्ञात वर्गों के लिए तेज़ डिटेक्शन


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-hi/vision-models/groundingdino.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
