> For the complete documentation index, see [llms.txt](https://docs.roboflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboflow.com/roboflow/roboflow-hi/deploy/supported-models/rf-detr.md).

# RF-DETR

## RF-DETR Object Detection

RF-DETR, Roboflow का transformer-आधारित real-time detection model है। COCO-pretrained object detection checkpoints के विरुद्ध inference चलाएँ [Serverless Hosted API](/roboflow/roboflow-hi/deploy/serverless-hosted-api-v2.md), या self-host using [Roboflow Inference](https://inference.roboflow.com/).

### कोड नमूना

नीचे दिए गए चरण RF-DETR को चलाते हैं [Serverless Hosted API](/roboflow/roboflow-hi/deploy/serverless-hosted-api-v2.md) और परिणामों को visualize करते हैं [supervision](https://supervision.roboflow.com/).

{% stepper %}
{% step %}
**अपनी API Key प्राप्त करें**

एक Roboflow खाता बनाएं, अपनी key यहाँ पर ढूँढें [Roboflow API settings page](https://app.roboflow.com/settings/api) और इसे अपने shell में उपलब्ध कराएँ:

```bash
export ROBOFLOW_API_KEY="your-key-here"
```

{% endstep %}

{% step %}
**निर्भरताएँ इंस्टॉल करें**

ये दो packages model को call करते हैं और इसके परिणामों को draw करते हैं:

```bash
pip install inference-sdk supervision
```

{% endstep %}

{% step %}
**मॉडल चलाएँ**

चलाएँ `rfdetr-small` एक sample image पर और boxes तथा labels annotate करें:

```python
import os
import cv2
import numpy as np
import requests
import supervision as sv
from inference_sdk import InferenceHTTPClient

image_url = "https://media.roboflow.com/quickstart/traffic.jpg"
content = requests.get(image_url).content
image = cv2.imdecode(np.frombuffer(content, np.uint8), cv2.IMREAD_COLOR)

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["ROBOFLOW_API_KEY"],
)
result = client.infer(image, model_id="rfdetr-small")

detections = sv.Detections.from_inference(result)

annotated = sv.BoxAnnotator().annotate(image.copy(), detections)
annotated = sv.LabelAnnotator().annotate(annotated, detections)

cv2.imwrite("traffic-annotated.png", annotated)
```

<figure><img src="/files/a04362d9a31dad5762167e3a32e4e9584fca2279" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

{% hint style="info" %}
सेट करें `api_url` को अपने deployment target से मिलाएँ:

* `https://serverless.roboflow.com` Serverless Hosted API के लिए।
* `http://localhost:9001` एक local [Inference](https://inference.roboflow.com/) server.
* आपका [Dedicated Deployment](/roboflow/roboflow-hi/deploy/dedicated-deployments.md) एक private endpoint के लिए URL.
  {% endhint %}

### Pretrained models और benchmarks

इनमें से किसी भी alias को बतौर पास करें `model_id` जब inference चलाया जा रहा हो। SDK प्रत्येक alias को underlying Roboflow project version से resolve करता है।

<table data-search="false"><thead><tr><th>उपनाम</th><th>इनपुट आकार</th><th>mAP50-95</th><th>ONNX latency (ms)*</th><th>TensorRT FP16 (ms)*</th></tr></thead><tbody><tr><td><code>rfdetr-nano</code></td><td>384x384</td><td>48.4</td><td>9.7</td><td>6.2</td></tr><tr><td><code>rfdetr-small</code></td><td>512x512</td><td>53.0</td><td>12.9</td><td>8.3</td></tr><tr><td><code>rfdetr-medium</code></td><td>576x576</td><td>54.7</td><td>16.3</td><td>9.5</td></tr><tr><td><code>rfdetr-large</code></td><td>704x704</td><td>56.5</td><td>25.6</td><td>11.6</td></tr><tr><td><code>rfdetr-xlarge</code></td><td>700x700</td><td>58.6</td><td>41.6</td><td>14.9</td></tr><tr><td><code>rfdetr-2xlarge</code></td><td>880x880</td><td>60.1</td><td>53.4</td><td>21.7</td></tr></tbody></table>

## RF-DETR Instance Segmentation

RF-DETR instance segmentation checkpoints भी प्रदान करता है, जो boxes के साथ-साथ masks की भी भविष्यवाणी करते हैं। उन्हें के माध्यम से चलाएँ [Serverless Hosted API](/roboflow/roboflow-hi/deploy/serverless-hosted-api-v2.md), या self-host using [Roboflow Inference](https://inference.roboflow.com/).

### कोड नमूना

अपनी API key सेट करें और ऊपर दिखाए अनुसार dependencies install करें, फिर एक segmentation checkpoint चलाएँ और उसके masks draw करें:

```python
import os
import cv2
import numpy as np
import requests
import supervision as sv
from inference_sdk import InferenceHTTPClient

image_url = "https://media.roboflow.com/quickstart/traffic.jpg"
content = requests.get(image_url).content
image = cv2.imdecode(np.frombuffer(content, np.uint8), cv2.IMREAD_COLOR)

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["ROBOFLOW_API_KEY"],
)
result = client.infer(image, model_id="rfdetr-seg-preview")

detections = sv.Detections.from_inference(result)

annotated = sv.MaskAnnotator().annotate(image.copy(), detections)
annotated = sv.LabelAnnotator().annotate(annotated, detections)

cv2.imwrite("traffic-annotated.png", annotated)
```

<figure><img src="/files/6819c14a7049568ebf87b11fdbe807aa786b4f54" alt=""><figcaption></figcaption></figure>

### Pretrained models और benchmarks

इनमें से किसी भी alias को बतौर पास करें `model_id` जब inference चलाया जा रहा हो। SDK प्रत्येक alias को underlying Roboflow project version से resolve करता है। Figures COCO पर mask mAP हैं `val`.

<table data-search="false"><thead><tr><th>उपनाम</th><th>इनपुट आकार</th><th>Mask mAP50-95</th><th>ONNX latency (ms)*</th><th>TensorRT FP16 (ms)*</th></tr></thead><tbody><tr><td><code>rfdetr-seg-nano</code></td><td>312x312</td><td>40.3</td><td>15.8</td><td>10.5</td></tr><tr><td><code>rfdetr-seg-small</code></td><td>384x384</td><td>43.1</td><td>19.3</td><td>11.9</td></tr><tr><td><code>rfdetr-seg-medium</code></td><td>432x432</td><td>45.3</td><td>23.9</td><td>14.1</td></tr><tr><td><code>rfdetr-seg-large</code></td><td>504x504</td><td>47.1</td><td>30.1</td><td>15.4</td></tr><tr><td><code>rfdetr-seg-xlarge</code></td><td>624x624</td><td>48.8</td><td>51.2</td><td>19.1</td></tr><tr><td><code>rfdetr-seg-2xlarge</code></td><td>768x768</td><td>49.9</td><td>89.6</td><td>25.6</td></tr></tbody></table>

***

\* Latency मापी जाती है [Roboflow Inference](https://inference.roboflow.com/) 1x NVIDIA L4 पर, batch size 1, 1,000 inferences का औसत (100 warmup)। डिफ़ॉल्ट `inference-gpu` install CUDA execution provider पर ONNX चलाता है; `inference-models[trt10]` extra जोड़ने से prebuilt TensorRT FP16 engine अपने-आप चयन हो जाता है। FP16, COCO `val2017`. Accuracy प्रकाशित COCO `val` spec है (देखें [RF-DETR announcement)](https://blog.roboflow.com/rf-detr/)).
