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

{% 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="/files/992ed1d096ad223e311265c4a0c5ae37f0bec1fa">/files/992ed1d096ad223e311265c4a0c5ae37f0bec1fa</a></td><td><a href="/pages/490e5c9f34a5287e12c2707f6ac35d340a870146">/pages/490e5c9f34a5287e12c2707f6ac35d340a870146</a></td></tr><tr><td><strong>Inference Library</strong></td><td>해당 <code>Inference</code> 자체 프로세스에서 모델을 실행하기 위한 Python 패키지입니다.</td><td><a href="/files/2c07b1617050f91a098dae021d993597b14dff2e">/files/2c07b1617050f91a098dae021d993597b14dff2e</a></td><td><a href="/pages/783b2a8d0168098f2ba73d622d363861f7c44ca7">/pages/783b2a8d0168098f2ba73d622d363861f7c44ca7</a></td></tr><tr><td><strong>기타 SDK</strong></td><td>웹 브라우저, iOS, 또는 임베디드 기기에서 모델을 실행하세요.</td><td><a href="/files/da071d69af1f757cb366cce89db8a8a211891fd1">/files/da071d69af1f757cb366cce89db8a8a211891fd1</a></td><td><a href="/pages/98423147431417a84b6f4ea38c497a09a4c34f7b">/pages/98423147431417a84b6f4ea38c497a09a4c34f7b</a></td></tr></tbody></table>

한 명 이상의 클라이언트나 언어가 예측을 필요로 하거나, 모델을 애플리케이션 의존성에서 분리하고 싶거나, 엣지 디바이스에 배포할 때는 서버를 사용하세요.

<figure><img src="/files/59c6ee88883f1e0db98c032ba6a119415ee52c54" 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",  # 자체 호스팅 서버
    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 릴리스 이상의 inference server가 필요합니다. 다음을 사용하세요: `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 Package 레퍼런스](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 %}
