> 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/guides/run-a-model-locally.md).

# Model को Local रूप से चलाएँ

[Roboflow Inference](https://inference.roboflow.com/) Roboflow के hosted models के पीछे का free, open-source engine है। आप वही models अपने कंप्यूटर पर चला सकते हैं: Docker container में Inference Server शुरू करें, फिर HTTP या Python के साथ उसे images भेजें [Inference SDK](https://inference.roboflow.com/inference_helpers/inference_sdk/). इसे खुद चलाने से आपकी images आपकी अपनी machine पर रहती हैं और आपको अपने setup पर पूरा नियंत्रण मिलता है।

## अपनी machine पर एक model चलाएँ

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

### Inference Server शुरू करें

`inference server start` शुरू करता है [Inference Server](https://inference.roboflow.com/quickstart/docker/) एक Docker container में और आपके hardware के लिए सही version चुनता है: CPU, NVIDIA GPU, या Jetson। [Docker](https://docs.docker.com/get-docker/) इंस्टॉल और चल रहा होना चाहिए।

```bash
pip install inference-cli && inference server start
```

Server इस पर listen करता है `http://localhost:9001`. Device-specific setup और troubleshooting के लिए, देखें [Inference install guide](https://inference.roboflow.com/install/).
{% endstep %}

{% step %}

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

`supervision` results को draw करता है और जोड़ता है `cv2` और `numpy`:

```bash
pip install supervision
```

{% endstep %}

{% step %}

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

image को अपने local server पर भेजें और एक ready-made [RF-DETR](/roboflow/roboflow-hi/deploy/supported-models/rf-detr.md) model चलाएँ। इस तरह के ready-made models को API key की जरूरत नहीं होती:

```python
import base64
import cv2
import numpy as np
import requests
import supervision as sv

content = requests.get("https://media.roboflow.com/quickstart/cars.jpg").content
image = cv2.imdecode(np.frombuffer(content, np.uint8), cv2.IMREAD_COLOR)
image_b64 = base64.b64encode(content).decode("utf-8")

result = requests.post(
    "http://localhost:9001/coco/38",  # coco/38 == rfdetr-nano
    data=image_b64,  # raw base64 in the body
    headers={"Content-Type": "application/x-www-form-urlencoded"},
).json()
detections = sv.Detections.from_inference(result)
print(f"Found {len(detections)} objects")

annotated = sv.BoxAnnotator().annotate(image.copy(), detections)
annotated = sv.LabelAnnotator().annotate(annotated, detections)
cv2.imwrite("output.jpg", annotated)
```

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

{% tab title="SDK (Python)" icon="python" %}
{% stepper %}
{% step %}

### Inference Server शुरू करें

`inference server start` शुरू करता है [Inference Server](https://inference.roboflow.com/quickstart/docker/) एक Docker container में और आपके hardware के लिए सही version चुनता है: CPU, NVIDIA GPU, या Jetson। [Docker](https://docs.docker.com/get-docker/) इंस्टॉल और चल रहा होना चाहिए।

```bash
pip install inference-cli && inference server start
```

Server इस पर listen करता है `http://localhost:9001`. Device-specific setup और troubleshooting के लिए, देखें [Inference install guide](https://inference.roboflow.com/install/).
{% endstep %}

{% step %}

### SDK इंस्टॉल करें

`supervision` results को draw करता है और जोड़ता है `cv2` और `numpy`:

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

{% endstep %}

{% step %}

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

client को अपने local server की ओर point करें और एक ready-made [RF-DETR](/roboflow/roboflow-hi/deploy/supported-models/rf-detr.md) model चलाएँ। इस तरह के ready-made models को API key की जरूरत नहीं होती:

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

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

client = InferenceHTTPClient(api_url="http://localhost:9001")
result = client.infer(image, model_id="rfdetr-nano")

detections = sv.Detections.from_inference(result)
print(f"Found {len(detections)} objects")

annotated = sv.BoxAnnotator().annotate(image.copy(), detections)
annotated = sv.LabelAnnotator().annotate(annotated, detections)
cv2.imwrite("output.jpg", annotated)
```

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

पहला request model डाउनलोड करता है, इसलिए इसमें कुछ सेकंड लग सकते हैं। बाद के requests तेज़ होते हैं।

<figure><img src="/files/00285435713e501164927717c6a391393b47c01d" alt="RF-DETR car and truck bounding boxes on a road scene"><figcaption><p>local inference server से RF-DETR detections</p></figcaption></figure>

## एक video प्रोसेस करें

Video पर model चलाने के लिए, आप उसे server पर भेजते हैं और हर frame वापस मिलता है, boxes पहले से drawn हुए, जैसे यह चलता है। अगर आपका computer साथ नहीं दे पाता, तो server real time में रहने के लिए frames छोड़ देता है। यह Python SDK और एक [Workflow](/roboflow/roboflow-hi/workflows/what-is-workflows.md): एक saved setup जो model चलाता है और आपके लिए results draw करता है।

{% hint style="info" %}
आप HTTP के माध्यम से भी video पर model चला सकते हैं, ऊपर image example की तरह एक-एक frame भेजकर (कोई streaming add-on नहीं चाहिए)। यह धीमा है: अगला frame शुरू होने से पहले हर frame भेजा, process किया, और drawn किया जाना होता है, इसलिए बीच में काफी इंतज़ार होता है। SDK पूरे video को stream करता है और एक साथ कई frames पर काम करता है, इसलिए यह बहुत बेहतर तरीके से साथ देता है।
{% endhint %}

{% stepper %}
{% step %}

### SDK इंस्टॉल करें

Streaming video को `webrtc` add-on चाहिए:

```bash
pip install "inference-sdk[webrtc]"
```

{% endstep %}

{% step %}

### Video पर model चलाएँ

```python
import cv2
from inference_sdk import InferenceHTTPClient
from inference_sdk.webrtc import VideoFileSource
import supervision as sv

client = InferenceHTTPClient.init(api_url="http://localhost:9001")

# वीडियो डाउनलोड+कैश करें
source = VideoFileSource("https://media.roboflow.com/quickstart/cars.mp4")
# अनुकूलित video streaming के लिए webrtc का उपयोग करता है
session = client.webrtc.stream(
    source=source,
    model_id="rfdetr-nano"
)

# on_frame main thread पर चलता है, इसलिए cv2.imshow सुरक्षित है
@session.on_frame
def show(frame, data):
    det = sv.Detections.from_inference(data)
    img = sv.BoxAnnotator().annotate(frame, det)
    img = sv.LabelAnnotator().annotate(img, det)
    cv2.imshow("RF-DETR", img)
    if cv2.waitKey(1) == ord("q"):
        session.close()

session.run()
cv2.destroyAllWindows()
```

{% endstep %}
{% endstepper %}

{% embed url="<https://media.roboflow.com/quickstart/cars-rfdetr-out.mp4>" %}

Workflows editor में दृश्य रूप से और समृद्ध pipelines (tracking, filtering, zones, notifications) बनाएं, फिर उन्हें उसी तरह चलाएँ। edge और video-stream deployment के लिए देखें [Workflows editor](/roboflow/roboflow-hi/workflows/create-a-workflow.md), फिर उन्हें उसी तरह चलाएँ। edge और video-stream deployment के लिए देखें [Deploy a Workflow](/roboflow/roboflow-hi/workflows/deploy-a-workflow.md).

## अन्य विकल्प

* Hardware चलाए बिना managed endpoint पसंद है? एक का उपयोग करें [Dedicated Deployment](/roboflow/roboflow-hi/deploy/dedicated-deployments.md) या [Serverless Hosted API](/roboflow/roboflow-hi/deploy/serverless-hosted-api-v2.md).
* On-premises, air-gapped, या Kubernetes deployment चाहिए? देखें [Enterprise Deployment](/roboflow/roboflow-hi/deploy/enterprise-deployment.md).
* में हर option की तुलना करें [Deploy a Model or Workflow](/roboflow/roboflow-hi/deploy/deployment-overview.md).
