> 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/deploy/supported-models/yolo11.md).

# YOLO11

YOLO11 object detection runs through the [Serverless Hosted API](/deploy/serverless-hosted-api-v2.md), pretrained on COCO at 640 input size. For self-hosted deployment, see [Roboflow Inference](https://inference.roboflow.com/).

## Code sample

This sample runs inference through the Serverless Hosted API, decodes the response with [`supervision`](https://supervision.roboflow.com/), and writes an annotated image to disk.

{% 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

These two packages call the model and draw its results:

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

{% endstep %}

{% step %}

#### Run the model

Run `yolov11n-640` on a sample image and annotate boxes and labels:

```python
import os
import cv2
import numpy as np
import requests
import supervision as sv
from inference_sdk import InferenceHTTPClient

image_url = "https://media.roboflow.com/quickstart/traffic.jpg"
content = requests.get(image_url).content
image = cv2.imdecode(np.frombuffer(content, np.uint8), cv2.IMREAD_COLOR)

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

results = client.infer(image, model_id="yolov11n-640")
detections = sv.Detections.from_inference(results)

annotated = sv.BoxAnnotator().annotate(image.copy(), detections)
annotated = sv.LabelAnnotator().annotate(annotated, detections)

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

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

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

* `https://serverless.roboflow.com` for the Serverless Hosted API.
* `http://localhost:9001` for a local [Inference](https://inference.roboflow.com/) server.
* Your [Dedicated Deployment](/deploy/dedicated-deployments.md) URL for a private endpoint.
  {% endhint %}

## Pretrained models and benchmarks

Pass any of these aliases as the `model_id`. The `inference-sdk` resolves each alias to a pretrained Roboflow Universe model; the `yolo11*` prefix variants resolve to the same models.

<table data-search="false"><thead><tr><th>Alias</th><th>Input Size</th><th>mAP50-95</th><th>ONNX latency (ms)*</th><th>TensorRT FP16 (ms)*</th></tr></thead><tbody><tr><td><code>yolov11n-640</code></td><td>640x640</td><td>39.5</td><td>3.4</td><td>2.2</td></tr><tr><td><code>yolov11s-640</code></td><td>640x640</td><td>47.0</td><td>4.5</td><td>2.5</td></tr><tr><td><code>yolov11m-640</code></td><td>640x640</td><td>51.5</td><td>8.3</td><td>3.5</td></tr><tr><td><code>yolov11l-640</code></td><td>640x640</td><td>53.4</td><td>10.7</td><td>4.3</td></tr><tr><td><code>yolov11x-640</code></td><td>640x640</td><td>54.7</td><td>18.8</td><td>7.1</td></tr></tbody></table>

\# YOLO11 Instance Segmentation

YOLO11 instance segmentation runs through the [Serverless Hosted API](/deploy/serverless-hosted-api-v2.md), pretrained on COCO at 640 input size. For self-hosted deployment, see [Roboflow Inference](https://inference.roboflow.com/).

## Code sample

Set your API key and install the dependencies as shown above, then run `yolov11n-seg-640` and annotate masks and labels:

```python
import os
import cv2
import numpy as np
import requests
import supervision as sv
from inference_sdk import InferenceHTTPClient

image_url = "https://media.roboflow.com/quickstart/traffic.jpg"
content = requests.get(image_url).content
image = cv2.imdecode(np.frombuffer(content, np.uint8), cv2.IMREAD_COLOR)

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

results = client.infer(image, model_id="yolov11n-seg-640")
detections = sv.Detections.from_inference(results)

annotated = sv.MaskAnnotator().annotate(image.copy(), detections)
annotated = sv.LabelAnnotator(text_position=sv.Position.CENTER_OF_MASS).annotate(annotated, detections)

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

<figure><img src="/files/cvRZiIbY8xoyTnZ7DIQ5" alt=""><figcaption></figcaption></figure>

## Pretrained models and benchmarks

Pass any of these aliases as the `model_id`; the `yolo11*` prefix variants resolve to the same models.

<table data-search="false"><thead><tr><th>Alias</th><th>Input Size</th><th>Box mAP50-95</th><th>Mask mAP50-95</th><th>ONNX latency (ms)*</th><th>TensorRT FP16 (ms)*</th></tr></thead><tbody><tr><td><code>yolov11n-seg-640</code></td><td>640x640</td><td>38.9</td><td>32.0</td><td>7.3</td><td>5.7</td></tr><tr><td><code>yolov11s-seg-640</code></td><td>640x640</td><td>46.6</td><td>37.8</td><td>10.0</td><td>7.5</td></tr><tr><td><code>yolov11m-seg-640</code></td><td>640x640</td><td>51.5</td><td>41.5</td><td>14.5</td><td>9.1</td></tr><tr><td><code>yolov11l-seg-640</code></td><td>640x640</td><td>53.4</td><td>42.9</td><td>16.8</td><td>9.7</td></tr><tr><td><code>yolov11x-seg-640</code></td><td>640x640</td><td>54.7</td><td>43.8</td><td>27.5</td><td>13.1</td></tr></tbody></table>

***

\* Latency is measured with [Roboflow Inference](https://inference.roboflow.com/) on 1x NVIDIA L4, batch size 1, mean of 1,000 inferences (100 warmup). The default `inference-gpu` install runs ONNX on the CUDA execution provider; adding the `inference-models[trt10]` extra selects a prebuilt TensorRT FP16 engine automatically. FP16 matches FP32 accuracy within 0.1 mAP on COCO `val2017`. Accuracy is the published COCO `val2017` spec ([source](https://docs.ultralytics.com/models/yolo11/)).
