> 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-ko/deploy/supported-models/rf-detr.md).

# RF-DETR

## RF-DETR 객체 감지

RF-DETR은 Roboflow의 transformer 기반 실시간 감지 모델입니다. COCO 사전 학습된 객체 감지 체크포인트에 대해 다음을 통해 inference를 실행하세요: [Serverless Hosted API](/roboflow/roboflow-ko/deploy/serverless-hosted-api-v2.md), 또는 다음을 사용해 자체 호스팅 [Roboflow Inference](https://inference.roboflow.com/).

### 코드 샘플

아래 단계에서는 RF-DETR을 다음을 통해 실행합니다 [Serverless Hosted API](/roboflow/roboflow-ko/deploy/serverless-hosted-api-v2.md) 그리고 다음을 사용해 결과를 시각화합니다 [supervision](https://supervision.roboflow.com/).

{% stepper %}
{% step %}
**API Key를 받으세요**

Roboflow 계정을 만들고, 다음에서 키를 찾으세요: [Roboflow API 설정 페이지](https://app.roboflow.com/settings/api) 그리고 이를 셸에서 사용할 수 있도록 설정하세요:

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

{% endstep %}

{% step %}
**종속성을 설치하세요**

이 두 패키지는 모델을 호출하고 결과를 그립니다:

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

{% endstep %}

{% step %}
**모델을 실행하세요**

실행 `rfdetr-small` 샘플 이미지에 대해 실행하고 박스와 레이블을 주석 처리합니다:

```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/239c9dfcee05cce618ecdf2628a3bf93261c6911" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

{% hint style="info" %}
설정 `api_url` 을 배포 대상에 맞게 설정하세요:

* `https://serverless.roboflow.com` Serverless Hosted API용입니다.
* `http://localhost:9001` 로컬 [Inference](https://inference.roboflow.com/) 서버용입니다.
* 귀하의 [Dedicated Deployment](/roboflow/roboflow-ko/deploy/dedicated-deployments.md) 비공개 엔드포인트용 URL입니다.
  {% endhint %}

### 사전 학습된 모델 및 벤치마크

이 별칭들 중 아무거나 다음으로 전달하세요: `model_id` inference를 실행할 때. SDK는 각 alias를 기반이 되는 Roboflow 프로젝트 버전으로 해석합니다.

<table data-search="false"><thead><tr><th>별칭</th><th>입력 크기</th><th>mAP50-95</th><th>ONNX 지연 시간(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 인스턴스 세그멘테이션

RF-DETR은 박스와 함께 마스크를 예측하는 instance segmentation 체크포인트도 제공합니다. 다음을 통해 실행하세요 [Serverless Hosted API](/roboflow/roboflow-ko/deploy/serverless-hosted-api-v2.md), 또는 다음을 사용해 자체 호스팅 [Roboflow Inference](https://inference.roboflow.com/).

### 코드 샘플

위에 나온 대로 API 키를 설정하고 dependencies를 설치한 다음, segmentation 체크포인트를 실행하고 마스크를 그리세요:

```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/b58691840a6a1da1912ed8f990b16415ce06f346" alt=""><figcaption></figcaption></figure>

### 사전 학습된 모델 및 벤치마크

이 별칭들 중 아무거나 다음으로 전달하세요: `model_id` inference를 실행할 때. SDK는 각 alias를 기반이 되는 Roboflow 프로젝트 버전으로 해석합니다. 수치는 COCO에서의 mask mAP입니다 `검증`.

<table data-search="false"><thead><tr><th>별칭</th><th>입력 크기</th><th>Mask mAP50-95</th><th>ONNX 지연 시간(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>

***

\* 지연 시간은 다음으로 측정됩니다: [Roboflow Inference](https://inference.roboflow.com/) 1x NVIDIA L4에서, batch size 1, 1,000회 inference의 평균(100회 워밍업). 기본 `inference-gpu` install은 ONNX를 CUDA execution provider에서 실행합니다. 다음을 추가하면 `inference-models[trt10]` extra가 사전 빌드된 TensorRT FP16 engine을 자동으로 선택합니다. FP16은 COCO에서 FP32 정확도와 0.2 mAP 이내로 일치합니다 `val2017`. 정확도는 공개된 COCO `검증` spec입니다(다음을 참조하세요: [RF-DETR 발표](https://blog.roboflow.com/rf-detr/)).
