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

# YOLOv7

당사의 YOLOv7 인스턴스 세그멘테이션 추론을 지원합니다. [서버리스 클라우드 API](https://docs.roboflow.com/deployment/roboflow-cloud/serverless-api). Roboflow에서는 YOLOv7 학습을 지원하지 않지만, 대신 [자체 가중치를 업로드하여](/models/ko/model-weights/upload-custom-weights.md) 그리고 이들에 대해 추론을 실행할 수 있습니다.

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

YOLOv7 입력 크기는 Roboflow 외부에서 모델을 학습할 때 설정됩니다(일반적인 값: 640x640 또는 1280x1280).

## YOLOv7 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를 설치하고 [supervision](https://supervision.roboflow.com/) 마스크를 디코딩하고 그리기 위해:

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

{% endstep %}

{% step %}

### 모델 실행

이 예제는 다음에서 학습된 공개 YOLOv7 인스턴스 세그멘테이션 모델을 실행합니다. [콘크리트 표면 결함](https://universe.roboflow.com/road-ywxxe/concrete-pugqq) (`concrete-pugqq/3`), 그런 다음 supervision을 사용해 예측된 마스크를 렌더링합니다. 자체 가중치를 서빙하려면, 다음으로 바꾸세요: `{workspace}/{model-slug}` ID(참조 [버전, 학습, 모델](/models/ko/versions-trainings-and-models.md)).

```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/docs/concrete-crack.jpg")

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["ROBOFLOW_API_KEY"],
).configure(InferenceConfiguration(api_key_transport="header"))
results = client.infer(image, model_id="concrete-pugqq/3")

detections = sv.Detections.from_inference(results)

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

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

<figure><img src="/files/05154d1aa8555e72c3fd645abba25aaeba9e7b2f" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

{% hint style="info" %}
설정하세요 `api_url` 를 배포 대상에 맞게:

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