> 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/inference-library.md).

# Inference Library

그 `추론` Python 패키지는 모델을 로드하고 자체 프로세스 내에서 실행합니다. 시작할 컨테이너도 없고 코드와 모델 사이에 HTTP 요청도 없기 때문에, 가장 낮은 지연 시간으로 자체 호스팅할 수 있고 기존 Python 애플리케이션에 가장 쉽게 임베드할 수 있는 방법입니다.

애플리케이션이 Python으로 작성되어 있고 모델과 같은 머신에서 실행될 때 사용하세요. 여러 클라이언트, 언어, 또는 비디오 스트림에 대한 예측이 필요하거나, 모델을 애플리케이션 의존성과 분리하고 싶다면 대신 [Inference Server](/deployment/ko/self-hosted/inference-server.md) 를 실행하세요. 둘 다 동일한 `model_id` 값을 받아서, 나중에 전환해도 작은 변경만 필요합니다.

## 설치

```bash
pip install inference
```

NVIDIA GPU가 있다면 대신 `inference-gpu` 를 설치하세요:

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

OS에 설치된 CUDA 버전에 맞게 `--extra-index-url` 를 설정하세요: `https://download.pytorch.org/whl/cu<major><minor>`, 예를 들어 `https://download.pytorch.org/whl/cu130` 은 CUDA 13.0용입니다. GPU 설치에는 OS에 CUDA가 필요합니다. 종속성이 없다면 다음 설치 가이드를 참조하세요: [Linux](https://docs.nvidia.com/cuda/cuda-installation-guide-linux/) 또는 [Windows](https://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/) CUDA 설치 가이드를 참조하세요.

부터 `추론` 1.2.0, 새로운 추론 엔진(`inference-models`)이 기본값입니다. TensorRT를 포함한 여러 모델 백엔드를 지원하며, 하드웨어에서 사용 가능한 가장 빠른 백엔드를 선택합니다. `추론` 설치되는 것은 `torch` 및 `onnx` 모델에 필요한 것들입니다. 다른 백엔드는 패키지 extra에서 제공합니다:

```bash
pip install inference-models[trt10]
```

Windows에서는 CUDA 설정에 추가 단계가 필요합니다. 다음을 참조하세요: [Windows에서 Bare Metal Inference GPU 설치하기](/deployment/ko/self-hosted/inference-library/bare-metal-gpu-windows.md).

## 모델 실행

```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()` 은 처음 사용할 때 모델 가중치를 다운로드하고 캐시한 다음, 로컬에서 추론을 실행합니다.  `model_id` 은 사전 학습된 별칭, 직접 미세 조정한 모델, 또는 Universe 모델일 수 있습니다. 다음을 참조하세요: [모델 ID](/deployment/ko/self-hosted/self-hosted.md#model-ids). 미세 조정된 모델과 Universe 모델에는 [API 키](https://docs.roboflow.com/reference/authentication/authentication/find-your-roboflow-api-key).

## 결과 시각화

설치 [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)
```

## 비디오 및 워크플로

대부분의 비디오 애플리케이션에서는 [Inference Server](/deployment/ko/self-hosted/inference-server.md) 을 실행하고 [Inference SDK WebRTC 클라이언트](https://docs.roboflow.com/reference/inference/inference-sdk/webrtc).

를 사용해 모델이나 워크플로를 스트리밍하세요. `InferencePipeline` 은 서버 없이 웹캠, RTSP 카메라 또는 비디오 파일을 처리할 수 있습니다. 이 직접 라이브러리 API를 사용하면 프로세스가 프레임, 사용자 지정 추론 로직, 그리고 싱크에 접근할 수 있습니다. 다음을 참조하세요: [Inference Pipeline](https://docs.roboflow.com/reference/inference/inference-python/inference-pipeline).

## 더 나아가기

* [Inference Python Package 참조](https://docs.roboflow.com/reference/inference/inference-python) - 전체 API 표면.
* [기본 Python API](https://docs.roboflow.com/reference/inference/inference-python/native-python-api) - 서버 없이 모델을 로드하고 워크플로를 실행합니다.
* [모델 가중치 다운로드](https://docs.roboflow.com/reference/inference/inference-python/offline-weights) - 오프라인 및 에어갭 호스트용 가중치 캐시.
* [Inference 벤치마크](https://docs.roboflow.com/reference/inference/inference-python/benchmarks) - 모델 및 하드웨어별 측정 처리량.
