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

# L2Cs-Net

L2Cs-Net은 얼굴을 감지하고 각 얼굴의 요(yaw)와 피치(pitch) 각도를 예측하는 시선 방향 추정 모델입니다. 이를 우리의 [서버리스 호스티드 API](https://docs.roboflow.com/deployment/roboflow-cloud/serverless-api).

{% hint style="warning" %}
**자가 호스팅 Inference에서 사용 중단되었습니다.** 시선 감지는 다음에서 사용 중단되었습니다. [Roboflow Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted) MediaPipe 종속성이 제거되었을 때. 영향을 받는 버전에서는 `/gaze/gaze_detection` 엔드포인트와 `Gaze` 모델 클래스는 예외를 발생시킵니다 `FeatureDeprecatedError` (HTTP 410 Gone)이며, 스텁 엔드포인트는 제거될 예정입니다. 다음을 설정하세요 `CORE_MODEL_GAZE_ENABLED=False` 이를 완전히 비활성화하려면 이 설정을 사용하세요. 이 기능이 필요하면 Roboflow에 문의하세요.
{% endhint %}

## 코드 샘플

다음을 사용하여 HTTP 엔드포인트를 통해 L2Cs-Net을 직접 실행하세요 `curl`, 또는 다음을 사용하여 [`inference-sdk`](https://docs.roboflow.com/reference/inference/inference-sdk) 래퍼를 사용합니다.

{% tabs %}
{% tab title="HTTP(curl)" icon="webhook" %}
{% stepper %}
{% step %}

### API 키 받기

Roboflow 계정을 만들고, 다음에서 키를 찾으세요 [Roboflow API 설정 페이지](https://app.roboflow.com/settings/api) 그리고 셸에서 사용할 수 있도록 설정하세요:

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

{% endstep %}

{% step %}

### 모델 실행하기

다음을 호출하세요: `/gaze/gaze_detection` 엔드포인트를 다음으로 `curl`:

```bash
curl --location 'https://serverless.roboflow.com/gaze/gaze_detection' \\
  --header 'Content-Type: application/json' \
  --data '{
    "api_key": "'"$ROBOFLOW_API_KEY"'",
    "image": {"type": "url", "value": "https://media.roboflow.com/inference/man.jpg"}
  }'
```

{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="SDK (Python)" icon="python" %}
{% stepper %}
{% step %}

### API 키 받기

Roboflow 계정을 만들고, 다음에서 키를 찾으세요 [Roboflow API 설정 페이지](https://app.roboflow.com/settings/api) 그리고 셸에서 사용할 수 있도록 설정하세요:

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

{% endstep %}

{% step %}

### 의존성 설치하기

이 패키지는 다음 모델을 호출합니다:

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

{% endstep %}

{% step %}

### 모델 실행하기

아래 코드 예제는 다음을 호출합니다 `detect_gazes`, 이는 동일한 `/gaze/gaze_detection` 엔드포인트를 사용합니다:

```python
import os
import supervision as sv
from inference_sdk import InferenceHTTPClient

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

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["ROBOFLOW_API_KEY"],
).select_api_v1()

result = client.detect_gazes(image)

for prediction in result[0]["predictions"]:
    face = prediction["face"]
    yaw = prediction["yaw"]
    pitch = prediction["pitch"]
    print(f"Face at ({face['x']}, {face['y']}) - yaw: {yaw:.3f}, pitch: {pitch:.3f}")
```

{% endstep %}
{% endstepper %}
{% endtab %}
{% endtabs %}

## 추론 속도

다음을 사용해 측정한 지연 시간 [Roboflow Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted) 1x NVIDIA L4, 배치 크기 1, 워밍업 후 평균.

<table data-search="false"><thead><tr><th>모델</th><th>지연 시간(ms)</th></tr></thead><tbody><tr><td><code>l2cs-net</code></td><td>6.0</td></tr></tbody></table>

모델이 입력으로 기대하는 단일 얼굴 크롭에서 측정됩니다.

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

* `https://serverless.roboflow.com` Serverless Hosted 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 %}

응답에는 다음이 포함된 목록이 있습니다 `예측값` (각각 다음을 포함합니다 `얼굴` 바운딩 박스, `랜드마크`, `요(yaw)`, 및 `피치(pitch)` 라디안 단위), `시간`, `time_face_det`, 및 `time_gaze_det`.

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

## Inference(자가 호스팅)와 함께 사용

L2Cs-Net은 로컬 [Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted) 서버에서도 제공할 수 있습니다:

```bash
pip install inference inference-cli inference-sdk
inference server start  # http://localhost:9001을 제공합니다
```

```python
import os
from inference_sdk import InferenceHTTPClient

client = InferenceHTTPClient(
    api_url="http://localhost:9001",
    api_key=os.environ["ROBOFLOW_API_KEY"],
)

client.detect_gazes(inference_input="./image.jpg")
```

모델은 감지된 얼굴마다 하나의 항목을 반환하며, 여기에는 얼굴 박스와 랜드마크, 그리고 `요(yaw)` 및 `피치(pitch)` 라디안 단위의

```python
[{'face': {'x': 1107.0, 'y': 1695.5, 'width': 1056.0, 'height': 1055.0,
           'confidence': 0.9356, 'class': 'face', 'class_id': 0,
           'landmarks': [{'x': 902.0, 'y': 1441.0}, {'x': 1350.0, 'y': 1449.0},
                         {'x': 1137.0, 'y': 1692.0}, {'x': 1124.0, 'y': 1915.0},
                         {'x': 625.0, 'y': 1551.0}, {'x': 1565.0, 'y': 1571.0}]},
  'pitch': 0.0295,
  'yaw': -0.0410}]
```

요(yaw)와 피치(pitch)를 공간상의 한 점으로 변환할 때는 얼굴이 카메라에서 대략 1미터 떨어져 있고 높이가 대략 250mm라고 가정합니다. 이는 웹캠 설정의 합리적인 출발점입니다.

해당 [시선 감지 예제](https://github.com/roboflow/inference) Inference 저장소의 예제는 웹캠에서 L2Cs-Net을 실행하고, 사람이 어디를 보고 있는지 계산한 뒤, 프레임에 주석을 추가하는 방법을 보여줍니다.

### Workflows의 실행 모드

다음에서 사용될 때 [Workflow](https://docs.roboflow.com/workflows), 시선 감지는 다음 두 가지 모드 중 하나로 실행됩니다:

* **로컬 실행**: 모델이 사용자의 Inference 서버에서 실행됩니다.
* **원격 실행** : 모델은 `detect_gazes()` 클라이언트 메서드를 통해 원격 Inference 서버에서 HTTP로 호출됩니다.

## 추가 읽을거리

* [시선 감지와 눈 추적: 방법 가이드](https://blog.roboflow.com/gaze-direction-position/)
