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

# L2CS-Net

L2CS-Net is a gaze direction estimation model that detects faces and predicts each face's yaw and pitch angles. You can run it through our [Serverless Cloud API](https://docs.roboflow.com/deployment/roboflow-cloud/serverless-api).

{% hint style="warning" %}
**Deprecated in self-hosted Inference.** Gaze detection was deprecated in [Roboflow Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted) when the MediaPipe dependency was removed. On affected versions, the `/gaze/gaze_detection` endpoint and the `Gaze` model class raise `FeatureDeprecatedError` (HTTP 410 Gone), and the stub endpoint is scheduled for removal. Set `CORE_MODEL_GAZE_ENABLED=False` to disable it outright. Contact Roboflow if you need this capability.
{% endhint %}

## L2CS-Net API

Run L2CS-Net through the HTTP endpoint directly with `curl`, or with the [`inference-sdk`](https://docs.roboflow.com/reference/inference/inference-sdk) wrapper.

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

### Get your API Key

Create a Roboflow account, find your key on the [Roboflow API settings page](https://app.roboflow.com/settings/api) and make it available to your shell:

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

{% endstep %}

{% step %}

### Run the model

Call the `/gaze/gaze_detection` endpoint with `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 %}

### Get your API Key

Create a Roboflow account, find your key on the [Roboflow API settings page](https://app.roboflow.com/settings/api) and make it available to your shell:

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

{% endstep %}

{% step %}

### Install the dependencies

This package calls the model:

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

{% endstep %}

{% step %}

### Run the model

The code sample below calls `detect_gazes`, which hits the same `/gaze/gaze_detection` endpoint:

```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 %}

## L2CS-Net inference speed

Latency measured with [Roboflow Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted) on 1x NVIDIA L4, batch size 1, mean after warmup.

<table data-search="false"><thead><tr><th>Model</th><th>Latency (ms)</th></tr></thead><tbody><tr><td><code>l2cs-net</code></td><td>6.0</td></tr></tbody></table>

Measured on a single face crop, which is what the model expects as input.

{% hint style="info" %}
Set `api_url` to match your deployment target:

* `https://serverless.roboflow.com` for the Serverless Cloud API.
* `http://localhost:9001` for a local [Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted) server.
* Your [Dedicated Deployment](https://docs.roboflow.com/deployment/roboflow-cloud/dedicated-deployments) URL for a private endpoint.
  {% endhint %}

The response contains a list with `predictions` (each with `face` bounding box, `landmarks`, `yaw`, and `pitch` in radians), `time`, `time_face_det`, and `time_gaze_det`.

For self-hosted deployments and additional examples, see the [Roboflow Inference docs](https://docs.roboflow.com/deployment/self-hosted/self-hosted).

## Run L2CS-Net with self-hosted Inference

L2CS-Net can also be served by a local [Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted) server:

```bash
pip install inference inference-cli inference-sdk
inference server start  # serves 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")
```

The model returns one entry per detected face, containing the face box and landmarks plus `yaw` and `pitch` in radians:

```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}]
```

Converting yaw and pitch into a point in space assumes faces are roughly one meter from the camera and roughly 250 mm tall, which is a reasonable starting point for webcam setups.

The [gaze detection example](https://github.com/roboflow/inference) in the Inference repository shows how to run L2CS-Net on a webcam, compute where a person is looking, and annotate the frame.

### Execution modes in Workflows

When used in a [Workflow](https://docs.roboflow.com/workflows), gaze detection runs in one of two modes:

* **Local execution**: the model runs on your Inference server.
* **Remote execution**: the model is invoked over HTTP on a remote Inference server through the `detect_gazes()` client method.

## Further reading

* [Gaze detection and eye tracking: a how-to guide](https://blog.roboflow.com/gaze-direction-position/)
