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

# DocTR

[DocTR](https://github.com/mindee/doctr) एक दस्तावेज़ OCR मॉडल है जिसे हमारे माध्यम से परिनियोजित किया जा सकता है [सर्वरलेस होस्टेड API](https://docs.roboflow.com/deployment/roboflow-cloud/serverless-api).

## कोड नमूना

DocTR को सीधे HTTP एंडपॉइंट के माध्यम से चलाएँ, इसके साथ `curl`, या साथ में [`inference-sdk`](https://docs.roboflow.com/reference/inference/inference-sdk) रैपर।

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

### अपनी API कुंजी प्राप्त करें

एक Roboflow खाता बनाएँ, अपनी कुंजी यहाँ खोजें [Roboflow API सेटिंग्स पेज](https://app.roboflow.com/settings/api) और इसे अपने shell के लिए उपलब्ध कराएँ:

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

{% endstep %}

{% step %}

### मॉडल चलाएँ

कॉल करें `/doctr/ocr` endpoint के साथ `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 कुंजी प्राप्त करें

एक Roboflow खाता बनाएँ, अपनी कुंजी यहाँ खोजें [Roboflow API सेटिंग्स पेज](https://app.roboflow.com/settings/api) और इसे अपने shell के लिए उपलब्ध कराएँ:

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

{% endstep %}

{% step %}

### निर्भरताएँ इंस्टॉल करें

यह पैकेज मॉडल को कॉल करता है:

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

{% endstep %}

{% step %}

### मॉडल चलाएँ

पाठ वाली छवि पर DocTR चलाएँ:

```python
import os
import supervision as sv
from inference_sdk import InferenceHTTPClient

# पाठ वाली नमूना छवि
image = sv.load_image_from_url("https://media.roboflow.com/inference/license_plate_1.jpg")

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://docs.roboflow.com/deployment/self-hosted/self-hosted) पर 1x NVIDIA L4, batch size 1, warmup के बाद औसत।

<table data-search="false"><thead><tr><th>मॉडल</th><th>Latency (ms)</th></tr></thead><tbody><tr><td><code>doctr</code></td><td>83.5</td></tr></tbody></table>

एक पूर्ण दस्तावेज़ छवि पर मापा गया (पाठ पहचान + मान्यता)।

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

* `https://serverless.roboflow.com` सर्वरलेस होस्टेड API के लिए।
* `http://localhost:9001` एक स्थानीय [Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted) server के लिए।
* आपका [समर्पित परिनियोजन](https://docs.roboflow.com/deployment/roboflow-cloud/dedicated-deployments) एक निजी endpoint के लिए URL।
  {% endhint %}

## Inference (self-hosted) के साथ उपयोग करें

DocTR एक मुख्य मॉडल है [Roboflow Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted)इसलिए यह आपके द्वारा होस्ट किए गए सर्वर पर भी चलता है। एक स्थानीय सर्वर शुरू करें, फिर उसी `ocr_image` कॉल को उस पर भेजें:

```bash
pip install inference-cli
inference server start  # http://localhost:9001 पर सेवा देता है
```

```python
import os
from inference_sdk import InferenceHTTPClient

client = InferenceHTTPClient(
    api_url="http://localhost:9001",
    api_key=os.environ["ROBOFLOW_API_KEY"],
)

result = client.ocr_image(inference_input="./container.jpg")
print(result)
```

प्रतिक्रिया में पहचाना गया पाठ और अनुमान समय शामिल होता है:

```
{'result': 'MSKU 0439215', 'time': 3.87}
```

## अधिक पढ़ें

* [OCR के साथ छवियों में पाठ कैसे पहचानें](https://blog.roboflow.com/ocr-api/)
