> 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/deploy/supported-models/yolov12.md).

# YOLOv12

हम YOLOv12 object detection inferencing का समर्थन अपने [Serverless Hosted API](/roboflow/roboflow-hi/deploy/serverless-hosted-api-v2.md). YOLOv12 पाँच आकारों में समर्थित है (`n`, `s`, `m`, `l`, `x`) ऑब्जेक्ट डिटेक्शन कार्य के लिए।

self-hosted deployment के लिए, देखें [Roboflow Inference](https://inference.roboflow.com/).

Roboflow पर अपना मॉडल train करते समय YOLOv12 input size सेट की जाती है (सामान्य मान: 640x640 या 1280x1280)।

## कोड नमूना

{% stepper %}
{% step %}

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

एक Roboflow खाता बनाएं, अपनी key यहाँ पर ढूँढें [Roboflow API settings page](https://app.roboflow.com/settings/api) और इसे अपने shell में उपलब्ध कराएँ:

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

{% endstep %}

{% step %}

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

इंस्टॉल करें [Inference SDK](https://inference.roboflow.com/inference_helpers/inference_sdk/) और [supervision](https://supervision.roboflow.com/) predictions को decode और visualize करने के लिए:

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

{% endstep %}

{% step %}

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

यह उदाहरण एक सार्वजनिक YOLOv12 मॉडल चलाता है, जिसे एक [screws dataset](https://universe.roboflow.com/erik-pe6au/rf-bolts) (screw, flat-washer, hex-nut). अपनी स्वयं की `{workspace}/{model-slug}` अपने प्रशिक्षित weights चलाने के लिए (देखें [Versions, Trainings, and Models](/roboflow/roboflow-hi/train/versions-trainings-and-models.md)).

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

content = requests.get("https://media.roboflow.com/docs/bolts.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.infer(image, model_id="erik-pe6au/bolts-uzqzc-4-yolo12s-t1")

detections = sv.Detections.from_inference(result)

annotated = sv.BoxAnnotator().annotate(image.copy(), detections)

cv2.imwrite("annotated.png", annotated)
```

<figure><img src="/files/4f65cc08e2309c8a6177748e3b9e6377022f52d5" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

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

* `https://serverless.roboflow.com` Serverless Hosted API के लिए।
* `http://localhost:9001` एक local [Inference](https://inference.roboflow.com/) server.
* आपका [Dedicated Deployment](/roboflow/roboflow-hi/deploy/dedicated-deployments.md) एक private endpoint के लिए URL.
  {% endhint %}
