> 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/doctr.md).

# DocTR

[DocTR](https://github.com/mindee/doctr) 우리의 [Serverless Hosted API](/roboflow/roboflow-ko/deploy/serverless-hosted-api-v2.md).

## 코드 샘플

다음과 함께 HTTP 엔드포인트를 통해 DocTR를 직접 실행하세요 `curl`또는 [`inference-sdk`](https://inference.roboflow.com/inference_helpers/inference_sdk/) 래퍼를 사용하세요.

{% tabs %}
{% tab title="HTTP (curl)" icon="webhook" %}
{% stepper %}
{% step %}

### API Key를 받으세요

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

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

{% endstep %}

{% step %}

### 모델을 실행하세요

다음에 호출하세요. `/doctr/ocr` 엔드포인트를 `curl`:

```bash
curl --location 'https://serverless.roboflow.com/doctr/ocr' \\
  --header 'Content-Type: application/json' \
  --data '{
    "api_key": "'"$ROBOFLOW_API_KEY"'",
    "image": {"type": "url", "value": "https://media.roboflow.com/inference/license_plate_1.jpg"}
  }'
```

{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="SDK (Python)" icon="python" %}
{% 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
```

{% endstep %}

{% step %}

### 모델을 실행하세요

텍스트가 포함된 이미지에서 DocTR를 실행하세요:

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

# 텍스트가 포함된 샘플 이미지
content = requests.get("https://media.roboflow.com/inference/license_plate_1.jpg").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.ocr_image(inference_input=image, model="doctr")

print(result["result"]) # 추출된 텍스트
```

위 코드는 추론 결과를 터미널에 출력합니다:

```
Mr
AUTPMATIC
280SE
34 T6511
```

{% endstep %}
{% endstepper %}
{% endtab %}
{% endtabs %}

## 추론 속도

다음 기준으로 측정한 지연 시간 [Roboflow Inference](https://inference.roboflow.com/) 1x NVIDIA L4에서, 배치 크기 1로, 워밍업 이후 평균값입니다.

<table data-search="false"><thead><tr><th>모델</th><th>지연 시간(ms)</th></tr></thead><tbody><tr><td><code>doctr</code></td><td>83.5</td></tr></tbody></table>

전체 문서 이미지에서 측정됨(텍스트 감지 및 인식 포함).

{% 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 %}
