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

# Roboflow 2.0

Roboflow 2.0 एक DeepLabv3-आधारित semantic segmentation मॉडल है। आप Roboflow प्लेटफ़ॉर्म पर Roboflow 2.0 मॉडल्स को train करते हैं और उन्हें हमारे माध्यम से deploy करते हैं [Serverless Hosted API](/roboflow/roboflow-hi/deploy/serverless-hosted-api-v2.md).

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

{% hint style="info" %}
Roboflow 2.0 के कोई public default models नहीं हैं। आप अपने स्वयं के trained model को उसके `project/version` identifier का उपयोग करके अपने [Roboflow Project](https://app.roboflow.com/).
{% endhint %}

## कोड उदाहरण

इंस्टॉल करें [Inference SDK](https://inference.roboflow.com/) और [supervision](https://supervision.roboflow.com/):

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

उस Roboflow 2.0 semantic segmentation मॉडल पर inference चलाएँ जिसे आपने train किया है, per-pixel class map को decode करें, और एक annotated PNG लिखें। बदलें `your-project/1` को अपने model URL और version से। अपना [Roboflow API Key](https://app.roboflow.com/settings/api) के माध्यम से `API_KEY` environment variable.

Response में एक `segmentation_mask` (base64-encoded grayscale PNG जिसमें हर pixel value एक class ID है और `0` background है) और एक `class_map` class IDs को class names से mapping करता है। Script इसे एक `sv.Detections` row प्रति class में विभाजित करता है ताकि `sv.MaskAnnotator` masks को source image पर overlay कर सके।

```python
import base64
import os
import urllib.request

import cv2
import numpy as np
import supervision as sv
from inference_sdk import InferenceHTTPClient

image_url = "https://storage.googleapis.com/com-roboflow-marketing/notebooks/examples/bicycle.png"
image_path = "bicycle.png"
urllib.request.urlretrieve(image_url, image_path)

image = cv2.imread(image_path)
OUTPUT_PATH = "annotated.png"

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.getenv("API_KEY"),
)
result = client.infer(image, model_id="your-project/1")
predictions = result["predictions"]

mask_bytes = base64.b64decode(predictions["segmentation_mask"])
class_map = predictions.get("class_map", {})
class_mask = cv2.imdecode(np.frombuffer(mask_bytes, np.uint8), cv2.IMREAD_GRAYSCALE)
class_mask = cv2.resize(class_mask, (image.shape[1], image.shape[0]), interpolation=cv2.INTER_NEAREST)

class_ids = [cid for cid in np.unique(class_mask).tolist() if cid != 0]
if class_ids:
    masks, xyxy, names = [], [], []
    for cid in class_ids:
        binary = class_mask == cid
        rows = np.where(np.any(binary, axis=1))[0]
        cols = np.where(np.any(binary, axis=0))[0]
        xyxy.append([cols[0], rows[0], cols[-1], rows[-1]])
        masks.append(binary)
        names.append(class_map.get(str(cid), str(cid)))

    detections = sv.Detections(
        xyxy=np.array(xyxy, dtype=np.float64),
        mask=np.array(masks),
        class_id=np.array(class_ids),
        data={"class_name": np.array(names)},
    )
    annotated = sv.MaskAnnotator().annotate(scene=image.copy(), detections=detections)
    annotated = sv.LabelAnnotator().annotate(scene=annotated, detections=detections)
else:
    annotated = image

cv2.imwrite(OUTPUT_PATH, annotated)
print(f"{OUTPUT_PATH} सहेजा गया")
```

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

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.roboflow.com/roboflow/roboflow-hi/deploy/supported-models/roboflow-2.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
