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

# Roboflow 2.0

Roboflow 2.0 의미론적 분할 모델을 서버리스 호스팅 API를 통해 사용

Roboflow 2.0은 DeepLabv3 기반 시맨틱 세그멘테이션 모델입니다. Roboflow 플랫폼에서 Roboflow 2.0 모델을 학습하고, 다음을 통해 배포할 수 있습니다. [서버리스 클라우드 API](https://docs.roboflow.com/deployment/roboflow-cloud/serverless-api).

자체 호스팅으로 배포하려면 다음을 참조하세요. [Roboflow Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted).

## Roboflow 2.0 API

{% stepper %}
{% step %}

### API 키 가져오기

Roboflow 계정을 만들고, 다음 페이지에서 키를 확인한 후 [Roboflow API 설정 페이지](https://app.roboflow.com/settings/api) 셸에서 사용할 수 있도록 설정합니다.

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

{% endstep %}

{% step %}

### 종속 항목 설치

다음을 설치합니다. [Inference SDK](https://docs.roboflow.com/deployment/self-hosted/self-hosted) 및 [supervision](https://supervision.roboflow.com/):

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

{% endstep %}

{% step %}

### 모델 실행

학습한 Roboflow 2.0 시맨틱 세그멘테이션 모델로 추론을 실행하고 주석이 추가된 PNG 파일을 저장합니다. 모델은 다음과 같은 `{workspace}/{model-slug}` ID로 지정합니다( [버전, 학습 및 모델](https://docs.roboflow.com/models/ko/versions-trainings-and-models.md)).

`sv.Detections.from_inference` (supervision 0.32.0 이상)는 결과의 각 클래스를 하나의 감지 항목으로 변환합니다. 이 항목의 마스크는 해당 클래스의 모든 픽셀을 포함하며, 이름은 결과의 `class_map`에서 가져옵니다. 클래스 ID 0(배경)은 제외됩니다. 마스크가 입력 이미지 크기와 일치하도록 클라이언트 측 이미지 축소를 비활성화하세요.

```python
import os
import cv2
import supervision as sv
from inference_sdk import InferenceHTTPClient, InferenceConfiguration

image = sv.load_image_from_url("https://media.roboflow.com/quickstart/traffic.jpg")

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["ROBOFLOW_API_KEY"],
).configure(InferenceConfiguration(
    api_key_transport="header",
    client_downsizing_disabled=True,
))
# 사전 학습된 별칭은 없습니다. 자체 모델을 학습하고 "your-project/1"을 모델 ID로 바꾸세요.
result = client.infer(image, model_id="your-project/1")

detections = sv.Detections.from_inference(result)

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

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

{% endstep %}
{% endstepper %}

{% hint style="info" %}
배포 대상에 맞게 `api_url` 을 설정합니다.

* `https://serverless.roboflow.com` 은 서버리스 클라우드 API에 사용합니다.
* `http://localhost:9001` 은 로컬 배포에 사용합니다. [추론](https://docs.roboflow.com/deployment/self-hosted/self-hosted) 서버.
* 사용자의 [전용 배포](https://docs.roboflow.com/deployment/roboflow-cloud/dedicated-deployments) 비공개 엔드포인트의 URL.
  {% endhint %}
