> 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/deployment/ko/self-hosted/self-hosted.md).

# 자체 호스팅 배포

오픈 소스 컴퓨터 비전 배포 프레임워크인 Inference를 사용해 자신의 하드웨어에서 Roboflow 모델과 워크플로를 실행합니다.

[추론](https://github.com/roboflow/inference) Inference는 오픈 소스 컴퓨터 비전 배포 허브입니다. 모델과 워크플로를 제공하고, 비디오 스트림을 관리하며, CPU와 GPU에 대한 추론을 최적화합니다. 로컬 처리, 지연 시간과 리소스 제어, 또는 오프라인 배포가 필요할 때 셀프 호스팅하세요. Apache 2.0 라이선스의 핵심은 Roboflow의 호스팅 API도 지원합니다.

셀프 호스팅 추론은 크레딧을 사용하지 않습니다. 자체 하드웨어에서 실행하는 이미지와 비디오 스트림은 무료이며, Credit Usage 페이지에서는 해당 미터가 레거시로 표시되고 비용이 청구되지 않습니다.

제한적인 라이선스(예: AGPL-3.0)가 있는 모델은 상업적 셀프 호스팅을 위해 상업용 라이선스가 필요합니다. 그 라이선스는 Enterprise 애드온입니다. Roboflow가 관리하는 클라우드 배포에는 요금제에 포함되어 있습니다. 다음을 참조하세요: [Roboflow 라이선싱](https://roboflow.com/licensing).

{% hint style="info" %}
셀프 호스팅은 인프라를 직접 관리한다는 뜻입니다. Roboflow가 서버를 운영해주길 원한다면 다음을 참조하세요: [전용 배포](/deployment/ko/roboflow-cloud/dedicated-deployments.md) 또는 [서버리스 클라우드 API](/deployment/ko/roboflow-cloud/serverless-api.md), 그리고 전체 [옵션 비교](/deployment/ko/choosing-a-deployment.md).
{% endhint %}

## 경로 선택

자체 하드웨어에서 모델을 실행하는 방법은 세 가지가 있습니다. 대부분의 프로젝트는 Inference Server를 사용합니다.

<table data-view="cards" data-search="false"><thead><tr><th></th><th></th><th data-hidden data-card-cover data-type="image">표지 이미지</th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Inference Server</strong></td><td>HTTP를 통해 모델과 워크플로를 제공하는 Docker 컨테이너입니다.</td><td><a href="https://1826078061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoksNmwps1HmYr8TqHDnX%2Fuploads%2Fgit-blob-0882029be46bf9b5f51ed63153561ef9b1601c81%2Fimg-card-selfhosted-server.svg?alt=media">img-card-selfhosted-server.svg</a></td><td><a href="/deployment/ko/self-hosted/inference-server.md">Inference 서버</a></td></tr><tr><td><strong>Inference Library</strong></td><td>해당 <code>inference</code> 는 프로세스 내에서 모델을 실행하기 위한 Python 패키지입니다.</td><td><a href="https://1826078061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoksNmwps1HmYr8TqHDnX%2Fuploads%2Fgit-blob-ad7692de6027c75ce46a265215e508f4fa769512%2Fimg-card-selfhosted-library.svg?alt=media">img-card-selfhosted-library.svg</a></td><td><a href="/deployment/ko/self-hosted/inference-library.md">Inference 라이브러리</a></td></tr><tr><td><strong>기타 SDK</strong></td><td>웹 브라우저, iOS 또는 임베디드 장치에서 모델을 실행합니다.</td><td><a href="https://1826078061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoksNmwps1HmYr8TqHDnX%2Fuploads%2Fgit-blob-1acbee3acb1b452e7e4c1a82cf4186704a455d88%2Fimg-card-sdks-more.svg?alt=media">img-card-sdks-more.svg</a></td><td><a href="/deployment/ko/self-hosted/sdks.md">기타 SDK</a></td></tr></tbody></table>

하나 이상의 클라이언트나 언어가 예측 결과를 필요로 하거나, 모델을 애플리케이션 의존성으로부터 분리하고 싶거나, 엣지 장치에 배포할 때는 서버를 사용하세요.

<figure><img src="https://1826078061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoksNmwps1HmYr8TqHDnX%2Fuploads%2Fgit-blob-9c74d4545aec14d51322649264d3a34526a3cc24%2Fimg-inference-diagram-v1.png?alt=media" alt="Roboflow Inference architecture diagram"><figcaption><p>Inference가 애플리케이션, 모델, Roboflow 플랫폼 사이에서 위치하는 곳</p></figcaption></figure>

## 로컬에서 모델 실행

대부분의 프로젝트에서는 Docker에서 Inference Server를 실행하고 다음을 사용해 요청을 보냅니다. `inference-sdk`. 이 SDK는 애플리케이션을 Inference Server에 연결하는 Python HTTP 클라이언트입니다. Python 프로세스 내부에서 모델을 직접 로드하고 실행해야 할 때는 Inference Library를 사용하세요. 두 경로 모두 동일한 `model_id` 값을 사용하므로 나중에 서로 전환할 수 있습니다.

### 모델 ID

해당 `model_id` 매개변수는 다음과 같을 수 있습니다:

* 하나의 [사전 학습된 모델 별칭](/models/ko/pretrained-aliases.md), 예를 들어 `rfdetr-small` 또는 `rfdetr-large`
* 자신의 [Roboflow에서 미세 조정한 모델](https://app.gitbook.com/s/wdr4k0gUcsVnXVoafYcQ/train/model-ids), 예를 들어 `my-project/1`
* 하나의 [Universe 모델](https://docs.roboflow.com/datasets/universe/universe/find-a-model-on-universe), 예를 들어 `soccer-players-xy9vk/2`

미세 조정된 모델과 Universe 모델에는 다음이 필요합니다 [API 키](https://docs.roboflow.com/reference/authentication/authentication/find-your-roboflow-api-key).

{% tabs %}
{% tab title="Inference Server" icon="docker" %}

### 설치

다음으로 서버를 시작하세요. [Inference CLI](https://docs.roboflow.com/reference/inference/inference-cli). 하드웨어를 감지하고 보안 기본값으로 올바른 Docker 이미지를 가져옵니다:

```bash
pip install inference-cli && inference server start
```

그다음 HTTP 클라이언트를 설치하세요:

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

하드웨어 요구 사항, 장치별 가이드, 수동 `docker run` 명령은 다음을 참조하세요: [Inference Server 설치](/deployment/ko/self-hosted/inference-server/install.md). 같은 클라이언트는 [서버리스 클라우드 API](/deployment/ko/roboflow-cloud/serverless-api.md) 그리고 [전용 배포](/deployment/ko/roboflow-cloud/dedicated-deployments.md)에서는 동일합니다: `api_url` 만 변경됩니다.

### 추론 실행

```python
from inference_sdk import InferenceHTTPClient, InferenceConfiguration

image = "https://media.roboflow.com/inference/people-walking.jpg"
client = InferenceHTTPClient(
    api_url="http://localhost:9001",  # your self-hosted server
    api_key="YOUR_API_KEY",
).configure(InferenceConfiguration(api_key_transport="header"))
results = client.infer(image, model_id="rfdetr-small")
```

해당 `api_key_transport="header"` 설정은 키를 다음 형식으로만 전송합니다: `Authorization: Bearer` 헤더로 보내며 URL과 로그에서 제외합니다. 이 기능은 1.5.0 이상 릴리스의 추론 서버가 필요합니다; 다음을 사용하세요. `api_key_transport="both"` 이전 서버를 계속 호출할 때는 사용하세요. 다음을 참조하세요: [API 키 전송](https://docs.roboflow.com/reference/inference/inference-sdk/configuration#api-key-transport).

다음으로 바꾸세요 `api_url` \~에 대해 `https://serverless.roboflow.com` 다음을 사용하려면 [서버리스 클라우드 API](/deployment/ko/roboflow-cloud/serverless-api.md) 다른 코드 변경 없이 대신 사용하세요. 다음을 참조하세요. [Inference SDK 레퍼런스](https://docs.roboflow.com/reference/inference/inference-sdk) 자세한 내용은

### 결과 시각화

설치 [Supervision](https://supervision.roboflow.com):

```bash
pip install -U supervision
```

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

image = sv.load_image_from_url("https://media.roboflow.com/inference/people-walking.jpg")

client = InferenceHTTPClient(
    api_url="http://localhost:9001",
    api_key="YOUR_API_KEY",
).configure(InferenceConfiguration(api_key_transport="header"))
results = client.infer(image, model_id="rfdetr-medium")

detections = sv.Detections.from_inference(results)

annotated_image = sv.BoxAnnotator().annotate(scene=image, detections=detections)
annotated_image = sv.LabelAnnotator().annotate(scene=annotated_image, detections=detections)

sv.plot_image(annotated_image)
```

{% endtab %}

{% tab title="Inference Library" icon="python" %}

### 설치

설치하세요 `inference` 패키지를 자체 Python 환경에:

```bash
pip install inference
```

NVIDIA GPU가 있다면 다음을 설치하세요 `inference-gpu` 대신, 인덱스 URL을 운영체제에 설치된 CUDA 버전에 맞추세요:

```bash
pip install --extra-index-url https://download.pytorch.org/whl/cu124 inference-gpu
```

참고 [Inference Library](/deployment/ko/self-hosted/inference-library.md) 백엔드 추가 기능 및 GPU 설정 자세한 내용은.

### 추론 실행

```python
from inference import get_model

image = "https://media.roboflow.com/inference/people-walking.jpg"
model = get_model(model_id="rfdetr-small")
results = model.infer(image)
```

`get_model()` 처음 사용할 때 모델 가중치를 다운로드하고 캐시한 다음 로컬에서 추론을 실행합니다. 다음을 참조하세요. [Inference Python 패키지 레퍼런스](https://docs.roboflow.com/reference/inference/inference-python) 자세한 내용은

### 결과 시각화

설치 [Supervision](https://supervision.roboflow.com):

```bash
pip install -U supervision
```

```python
import supervision as sv
from inference import get_model

image = sv.load_image_from_url("https://media.roboflow.com/inference/people-walking.jpg")

model = get_model(model_id="rfdetr-medium")
results = model.infer(image)[0]

detections = sv.Detections.from_inference(results)

annotated_image = sv.BoxAnnotator().annotate(scene=image, detections=detections)
annotated_image = sv.LabelAnnotator().annotate(scene=annotated_image, detections=detections)

sv.plot_image(annotated_image)
```

{% endtab %}
{% endtabs %}

![탐지 결과로 주석이 달린 걸어가는 사람들](https://storage.googleapis.com/com-roboflow-marketing/inference/people-walking-annotated.jpg)

{% hint style="warning" %}
API 키를 외부 사용자에게 노출하지 않도록 주의하세요. 공개용 프런트엔드 앱에 직접 포함하지 말고, 대신 요청을 자체 백엔드로 프록시하세요.
{% endhint %}

다음을 실행할 수 있습니다. [워크플로](https://docs.roboflow.com/workflows) 서버 또는 자신의 프로세스에서 같은 방식으로: 다음을 참조하세요. [워크플로 배포](https://docs.roboflow.com/workflows/deploy/deploy-a-workflow).

{% hint style="info" %}
비공개 모델용 TensorRT 최적화 모델 패키지는 다음에서만 사용할 수 있습니다. [엔터프라이즈 요금제](/deployment/ko/self-hosted/enterprise.md) Roboflow 플랫폼 외부에서 Inference를 실행할 때입니다. 공개 모델에는 모든 요금제에 TensorRT 패키지가 포함됩니다.
{% endhint %}
