> 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-ko/deploy/supported-models/roboflow-2.md).

# Roboflow 2.0

Roboflow 2.0은 DeepLabv3 기반 시맨틱 세그멘테이션 모델입니다. Roboflow 플랫폼에서 Roboflow 2.0 모델을 학습하고, 당사의 [Serverless Hosted API](/roboflow/roboflow-ko/deploy/serverless-hosted-api-v2.md).

셀프 호스팅 배포는 다음을 참조하세요 [Roboflow Inference](https://inference.roboflow.com/).

{% hint style="info" %}
Roboflow 2.0에는 공개 기본 모델이 없습니다. 학습한 자체 모델은 해당 `project/version` 귀하의 [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 시맨틱 세그멘테이션 모델에 대해 inference를 실행하고, 픽셀별 클래스 맵을 디코딩한 뒤, 주석이 추가된 PNG를 작성합니다. 다음을 바꾸세요 `your-project/1` 모델 URL과 버전으로. 귀하의 [Roboflow API Key](https://app.roboflow.com/settings/api) 를 `API_KEY` 환경 변수.

응답에는 다음이 포함됩니다: `segmentation_mask` (base64로 인코딩된 그레이스케일 PNG로, 각 픽셀 값이 클래스 ID이며 `0` 0은 배경)와 `class_map` 클래스 ID를 클래스 이름에 매핑하는 맵입니다. 스크립트는 이를 하나의 `sv.Detections` 클래스당 한 행씩으로 분할하므로 `sv.MaskAnnotator` 가 소스 이미지 위에 마스크를 오버레이할 수 있습니다.

```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` 를 배포 대상에 맞게:

* `https://serverless.roboflow.com` Serverless Hosted API용.
* `http://localhost:9001` 로컬 [Inference](https://inference.roboflow.com/) 서버용.
* 귀하의 [Dedicated Deployment](/roboflow/roboflow-ko/deploy/dedicated-deployments.md) 개인 엔드포인트용 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-ko/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.
