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

# YOLOv7

हम अपने माध्यम से YOLOv7 instance segmentation inferencing का समर्थन करते हैं [Serverless Hosted API](/roboflow/roboflow-hi/deploy/serverless-hosted-api-v2.md). YOLOv7 को train करना Roboflow पर समर्थित नहीं है, लेकिन आप [अपने स्वयं के weights अपलोड कर सकते हैं](/roboflow/roboflow-hi/deploy/upload-custom-weights.md) और उन पर inference चला सकते हैं।

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

YOLOv7 input size तब सेट की जाती है जब आप अपना model Roboflow के बाहर train करते हैं (सामान्य मान: 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 इंस्टॉल करें और [supervision](https://supervision.roboflow.com/) masks को decode और draw करने के लिए:

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

{% endstep %}

{% step %}

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

यह उदाहरण एक public YOLOv7 instance segmentation model चलाता है, जिसे इस पर train किया गया है [concrete surface defects](https://universe.roboflow.com/road-ywxxe/concrete-pugqq) (`concrete-pugqq/3`), फिर predicted masks को render करने के लिए supervision का उपयोग करता है। अपने स्वयं के weights serve करने के लिए, अपने `{workspace}/{model-slug}` ID (देखें [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/concrete-crack.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"],
)
results = client.infer(image, model_id="concrete-pugqq/3")

detections = sv.Detections.from_inference(results)

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

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

<figure><img src="/files/fd7e58cdcc0dbf5d47ff966334e7125346d7d046" 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 %}
