> 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/reference/hi/inference/inference-python.md).

# इन्फरेंस Python पैकेज

यह `इन्फरेंस` Python पैकेज मुख्य ओपन-सोर्स लाइब्रेरी है जो Roboflow के कंप्यूटर विज़न डिप्लॉयमेंट स्टैक को संचालित करती है। यह मॉडल लोडिंग, प्री/पोस्ट-प्रोसेसिंग, GPU/CPU ऑप्टिमाइज़ेशन, और [वर्कफ़्लोज़](https://docs.roboflow.com/workflows) निष्पादन प्रदान करता है, जिसे सीधे Python से कॉल किया जा सकता है।

यह [Inference Server](https://docs.roboflow.com/deployment/self-hosted/inference-server) इस पैकेज को रैप करता है और इसे HTTP के माध्यम से उपलब्ध कराता है (सभी निर्भरताओं के इंस्टॉल होने के साथ Docker इमेज के रूप में वितरित), लेकिन आप इसका उपयोग भी कर सकते हैं `इन्फरेंस` सीधे अपनी स्क्रिप्ट्स और एप्लिकेशनों में।

## ये हिस्से कैसे एक साथ काम करते हैं

Inference में कई घटक हैं जो कंप्यूटर विज़न मॉडल सर्व करने के लिए साथ मिलकर काम करते हैं:

* [**इन्फरेंस**](/reference/hi/inference/inference-python.md) - मॉडल लोडिंग, inference, और Workflows निष्पादन के लिए मुख्य Python पैकेज।
* [**इन्फरेंस-sdk**](/reference/hi/inference/inference-sdk.md) - HTTP के माध्यम से Inference Server से संचार करने के लिए हल्का Python क्लाइंट।
* [**इन्फरेंस-cli**](/reference/hi/inference/inference-cli.md) - Inference Server को प्रबंधित करने और सामान्य कार्य चलाने के लिए कमांड-लाइन टूल।
* [**Inference Server**](https://docs.roboflow.com/deployment/self-hosted/inference-server) - HTTP सर्वर (Docker) जो रैप करता है `इन्फरेंस` पैकेज को एक REST API के रूप में।

रनटाइम पर ये हिस्से कैसे व्यवहार करते हैं (request routing, parallelization, microservice और appliance patterns), इसके लिए देखें [इन्फरेंस आर्किटेक्चर](https://docs.roboflow.com/deployment/self-hosted/inference-server/architecture).

## मल्टी-बैकएंड समर्थन

Inference 1.0 कई inference runtime backends का समर्थन करता है: ONNX, TensorRT, Hugging Face, और PyTorch. यह आपके हार्डवेयर के लिए स्वतः सबसे तेज़ उपलब्ध backend चुनता है। उदाहरण के लिए, यदि आपके पास NVIDIA GPU है या आप Jetson डिवाइस पर चल रहे हैं और आपके प्लेटफ़ॉर्म पर मॉडल के लिए TensorRT engine उपलब्ध है, तो Inference डिफ़ॉल्ट रूप से TensorRT का उपयोग करता है।

## इंस्टॉलेशन

हम सलाह देते हैं कि आप [Python virtual environment (venv)](https://docs.python.org/3/tutorial/venv.html) का उपयोग करें ताकि Inference की dependencies को अलग रखा जा सके।

pip के माध्यम से Inference इंस्टॉल करने के लिए:

```bash
pip install inference
```

यदि आपके पास NVIDIA GPU है, तो आप अपने inference को इस तरह तेज़ कर सकते हैं:

```bash
pip install --extra-index-url https://download.pytorch.org/whl/cu124 inference-gpu
# कृपया --extra-index-url को अपने OS में स्थापित CUDA version के अनुसार समायोजित करें
# https://download.pytorch.org/whl/cu<major><minor>, उदाहरण के लिए CUDA 13.0 के लिए https://download.pytorch.org/whl/cu130
```

## त्वरित उदाहरण

आप inference को HTTP के माध्यम से Inference Server के विरुद्ध चला सकते हैं (के साथ `इन्फरेंस-sdk`) या सीधे अपने प्रोसेस में (मूल `इन्फरेंस` पैकेज के साथ)। मूल `get_model()` call मॉडल को आपकी स्क्रिप्ट में लोड करता है और एक ऑब्जेक्ट लौटाता है जिसे आप कॉल कर सकते हैं `.infer()` उस पर; HTTP क्लाइंट छवि को एक सर्वर पर भेजता है जो वही काम करता है।

{% tabs %}
{% tab title="inference (मूल)" %}

```python
from inference import get_model

model = get_model(model_id="rfdetr-small")
results = model.infer("https://media.roboflow.com/inference/people-walking.jpg")
```

{% endtab %}

{% tab title="inference-sdk (HTTP क्लाइंट)" %}

```python
from inference_sdk import InferenceHTTPClient

client = InferenceHTTPClient(
    # api_url="http://localhost:9001",  # self-hosted के लिए
    api_url="https://serverless.roboflow.com",
    api_key="ROBOFLOW_API_KEY",
)
results = client.infer(
    "https://media.roboflow.com/inference/people-walking.jpg",
    model_id="rfdetr-small",
)
```

{% endtab %}
{% endtabs %}

API key की आवश्यकता वाले मॉडल का उपयोग करने के लिए, सेट करें `ROBOFLOW_API_KEY` environment variable, या इसे सीधे पास करें:

```python
model = get_model(model_id="my-project/1", api_key="ROBOFLOW_API_KEY")
```

देखें [मूल Python API](/reference/hi/inference/inference-python/native-python-api.md) विज़ुअलाइज़ेशन सहित अधिक विस्तृत walkthrough के लिए पेज, और [मॉडल चलाएँ](https://docs.roboflow.com/deployment/self-hosted/self-hosted#run-a-model) server-आधारित पथ के लिए।

## Inference Pipeline

`InferencePipeline` वीडियो को उसी Python process के भीतर चलाता है जैसे `इन्फरेंस` पैकेज। इसका उपयोग केवल तब करें जब आप direct Inference Library execution चुनते हैं और उसकी custom logic या sink interfaces तक पहुँच चाहिए। जो Applications Inference Server या Serverless का उपयोग करती हैं, उन्हें उपयोग करना चाहिए [WebRTC Streaming](/reference/hi/inference/inference-sdk/webrtc.md).

```python
from inference import InferencePipeline
from inference.core.interfaces.stream.sinks import render_boxes

pipeline = InferencePipeline.init(
    model_id="rfdetr-large",
    video_reference="https://storage.googleapis.com/com-roboflow-marketing/inference/people-walking.mp4",
    on_prediction=render_boxes,
    api_key="ROBOFLOW_API_KEY",
)

pipeline.start()
pipeline.join()
```

ऊपर का कोड object detection annotation सीधे करता है (के माध्यम से `render_boxes` sink)। अधिक जानकारी के लिए, देखें [Inference Pipeline](/reference/hi/inference/inference-python/inference-pipeline.md) पेज।

## योगदान

Inference ओपन सोर्स है। source code, issue tracker, और contribution guide निम्न में उपलब्ध हैं [roboflow/inference](https://github.com/roboflow/inference) repository; देखें [CONTRIBUTING.md](https://github.com/roboflow/inference/blob/main/CONTRIBUTING.md) शुरू करने के लिए।

## अगले चरण

* [मूल Python API](/reference/hi/inference/inference-python/native-python-api.md) - मॉडल लोड करें और अपने प्रोसेस में inference चलाएँ।
* [Inference Pipeline](/reference/hi/inference/inference-python/inference-pipeline.md) - वीडियो स्ट्रीम्स पर मॉडल चलाएँ।
* [Model Weights Download](/reference/hi/inference/inference-python/offline-weights.md) - weight caching और persistent storage।
* [बेंचमार्क](/reference/hi/inference/inference-python/benchmarks.md) - सामान्य हार्डवेयर पर मापा गया throughput।
