# yolo

Python API: `depthai_nodes.node.parsers.utils.yolo`

## Classes

| Name | Description |
| --- | --- |
| [`YOLOSubtype`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/utils/yolo.md#yolo-Classes-YOLOSubtype) |  |

### class `YOLOSubtype`

```python
class YOLOSubtype(str, Enum)
```

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `DEFAULT` | `str` |  |
| `GOLD` | `str` |  |
| `P` | `str` |  |
| `V10` | `str` |  |
| `V11` | `str` |  |
| `V12` | `str` |  |
| `V26` | `str` |  |
| `V3` | `str` |  |
| `V3T` | `str` |  |
| `V3U` | `str` |  |
| `V3UT` | `str` |  |
| `V4` | `str` |  |
| `V4T` | `str` |  |
| `V5` | `str` |  |
| `V5U` | `str` |  |
| `V6` | `str` |  |
| `V6R1` | `str` |  |
| `V6R2` | `str` |  |
| `V7` | `str` |  |
| `V8` | `str` |  |
| `V9` | `str` |  |

## Functions

| Name | Description |
| --- | --- |
| [`compute_yolo_detections`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/utils/yolo.md#yolo-Functions-compute_yolo_detections) | Decode YOLO detection, pose, or segmentation tensors. |
| [`decode_yolo26`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/utils/yolo.md#yolo-Functions-decode_yolo26) | Decode YOLO26 output for detection, segmentation, or pose. |
| [`decode_yolo_output`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/utils/yolo.md#yolo-Functions-decode_yolo_output) | Decode the output of an YOLO instance segmentation or pose estimation model. |
| [`make_grid_numpy`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/utils/yolo.md#yolo-Functions-make_grid_numpy) | Create a grid of shape (1, na, ny, nx, 2) |
| [`non_max_suppression`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/utils/yolo.md#yolo-Functions-non_max_suppression) | Performs Non-Maximum Suppression (NMS) on inference results. |
| [`parse_kpts`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/utils/yolo.md#yolo-Functions-parse_kpts) | Parse keypoints. |
| [`parse_yolo_output`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/utils/yolo.md#yolo-Functions-parse_yolo_output) | Parse a single channel output of an YOLO model. |
| [`resolve_yolo_strides`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/utils/yolo.md#yolo-Functions-resolve_yolo_strides) | Resolve YOLO strides from metadata or default fallback. |

### function `compute_yolo_detections`

```python
def compute_yolo_detections(
    *,
    subtype: YOLOSubtype,
    layer_names: list[str],
    outputs_values: list[np.ndarray],
    strides: list[int] | None = None,
    conf_threshold: float,
    n_classes: int,
    iou_threshold: float,
    max_det: int,
    anchors: np.ndarray | None,
    n_keypoints: int,
    label_names: list[str] | None,
    keypoint_label_names: list[str] | None,
    keypoint_edges: list[tuple[int, int]] | None,
    input_shape: tuple[int, int] | None = None,
    kpts_outputs: list[np.ndarray] | None = None,
    masks_outputs_values: list[np.ndarray] | None = None,
    protos_output: np.ndarray | None = None,
    protos_len: int | None = None,
    mask_conf: float = 0.5,
    v26_mask_coeffs: np.ndarray | None = None,
    v26_protos: np.ndarray | None = None,
    v26_pose_kpts: np.ndarray | None = None,
) -> dict[str, np.ndarray | list[str] | int | None]
```

Decode YOLO detection, pose, or segmentation tensors.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `subtype` | `YOLOSubtype` | YOLO variant controlling tensor decoding. | required |
| `layer_names` | `list[str]` | Output layer names used to distinguish detection, pose, and segmentation modes. | required |
| `outputs_values` | `list[np.ndarray]` | Detection tensors ordered by output head. | required |
| `strides` | `list[int] | None` | Output head strides. If omitted, use the subtype-specific defaults. | `None` |
| `conf_threshold` | `float` | Minimum detection confidence used to filter candidates. | required |
| `n_classes` | `int` | Number of object classes encoded in the detection tensors. | required |
| `iou_threshold` | `float` | Intersection-over-union threshold for non-maximum suppression. | required |
| `max_det` | `int` | Maximum retained YOLO26 detections. Other subtypes use the suppression defaults in `decode_yolo_output`. | required |
| `anchors` | `np.ndarray | None` | Precomputed anchor coordinates used to decode model predictions. | required |
| `n_keypoints` | `int` | Number of keypoints encoded per prediction. | required |
| `label_names` | `list[str] | None` | Optional class-name lookup indexed by predicted class ID. | required |
| `keypoint_label_names` | `list[str] | None` | Optional names for the keypoints in each detection. | required |
| `keypoint_edges` | `list[tuple[int, int]] | None` | Optional pairs of keypoint indexes defining skeleton edges. | required |
| `input_shape` | `tuple[int, int] | None` | Model input image shape as `(height, width)`. | `None` |
| `kpts_outputs` | `list[np.ndarray] | None` | Per-head pose tensors for non-YOLO26 models. | `None` |
| `masks_outputs_values` | `list[np.ndarray] | None` | Mask coefficient tensors ordered to match the detection heads. | `None` |
| `protos_output` | `np.ndarray | None` | Batched prototype tensor with shape `(1, channels, height, width)`. | `None` |
| `protos_len` | `int | None` | Number of prototype channels used by each mask coefficient vector. | `None` |
| `mask_conf` | `float` | Probability threshold used to binarize mask logits. | `0.5` |
| `v26_mask_coeffs` | `np.ndarray | None` | YOLO26 mask coefficients aligned with detection queries. | `None` |
| `v26_protos` | `np.ndarray | None` | YOLO26 prototype masks. | `None` |
| `v26_pose_kpts` | `np.ndarray | None` | YOLO26 pose coordinates and confidences aligned with detection queries. | `None` |

Returns

| Type | Description |
| --- | --- |
| `dict[str, np.ndarray | list[str] | int | None]` | A dictionary containing `mode` (0 detection, 1 pose, 2 segmentation), normalized `bboxes`, `scores`, `labels`, `label_names`, `keypoints`, `keypoints_scores`, `keypoint_label_names`, `keypoint_edges`, and `masks`. Boxes use center-XY/width/height. A segmentation mask contains int16 detection indexes and -1 background; other modes return `None` for masks. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If required YOLO26 input geometry or detection outputs are missing, class/keypoint counts disagree with tensor shapes, or the mask instance count exceeds int16 capacity. |

### function `decode_yolo26`

```python
def decode_yolo26(
    raw: np.ndarray,
    conf_threshold: float,
    max_det: int,
    extra_raw: np.ndarray | None = None,
) -> tuple[np.ndarray, np.ndarray | None]
```

Decode YOLO26 output for detection, segmentation, or pose.

YOLO26 end2end output is already decoded to xyxy pixel boxes and includes a pre-computed confidence score (ReduceMax over class
scores) in column 4. This path only applies confidence thresholding and top-k filtering. It can also filter an auxiliary tensor
such as mask coefficients or keypoints using the kept rows.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `raw` | `np.ndarray` | Raw detection tensor (N, A, 5+nc) where columns are [x1, y1, x2, y2, conf, cls_0, ..., cls_nc-1]. | required |
| `conf_threshold` | `float` | Confidence threshold. | required |
| `max_det` | `int` | Maximum number of detections. | required |
| `extra_raw` | `np.ndarray | None` | Optional auxiliary tensor (N, A, M) such as mask coefficients or keypoints. When provided the kept rows are returned as the second element. | `None` |

Returns

| Type | Description |
| --- | --- |
| `tuple[np.ndarray, np.ndarray | None]` | Tuple of (detection results (K, 6), kept auxiliary data (K, M) or None). |

### function `decode_yolo_output`

```python
def decode_yolo_output(
    yolo_outputs: list[np.ndarray],
    strides: list[int],
    anchors: np.ndarray | None = None,
    kpts: list[np.ndarray] | None = None,
    conf_thres: float = 0.5,
    iou_thres: float = 0.45,
    num_classes: int = 1,
    det_mode: bool = False,
    subtype: YOLOSubtype = YOLOSubtype.DEFAULT,
    max_nms: int = 3000,
) -> np.ndarray
```

Decode the output of an YOLO instance segmentation or pose estimation model.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `yolo_outputs` | `list[np.ndarray]` | List of YOLO outputs. | required |
| `strides` | `list[int]` | List of strides. | required |
| `anchors` | `np.ndarray | None` | An optional array of anchors. | `None` |
| `kpts` | `list[np.ndarray] | None` | An optional list of keypoints. | `None` |
| `conf_thres` | `float` | Confidence threshold. | `0.5` |
| `iou_thres` | `float` | Intersection over union threshold. | `0.45` |
| `num_classes` | `int` | Number of classes. | `1` |
| `det_mode` | `bool` | Detection only mode. If True, the output will only contain bbox detections. | `False` |
| `subtype` | `YOLOSubtype` | YOLO version. | `YOLOSubtype.DEFAULT` |
| `max_nms` | `int` | Maximum number of boxes to keep after NMS. | `3000` |

Returns

| Type | Description |
| --- | --- |
| `np.ndarray` | NMS output. |

### function `make_grid_numpy`

```python
def make_grid_numpy(ny: int, nx: int, na: int) -> np.ndarray
```

Create a grid of shape (1, na, ny, nx, 2)

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `ny` | `int` | Number of y coordinates. | required |
| `nx` | `int` | Number of x coordinates. | required |
| `na` | `int` | Number of anchors. | required |

Returns

| Type | Description |
| --- | --- |
| `np.ndarray` | Grid. |

### function `non_max_suppression`

```python
def non_max_suppression(
    prediction: np.ndarray,
    conf_thres: float = 0.5,
    iou_thres: float = 0.45,
    classes: list | None = None,
    num_classes: int = 1,
    agnostic: bool = False,
    multi_label: bool = False,
    max_det: int = 300,
    max_time_img: float = 0.05,
    max_nms: int = 30000,
    max_wh: int = 7680,
    kpts_mode: bool = False,
    det_mode: bool = False,
) -> list[np.ndarray]
```

Performs Non-Maximum Suppression (NMS) on inference results.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `prediction` | `np.ndarray` | Prediction from the model, shape = (batch_size, boxes, xy+wh+...) | required |
| `conf_thres` | `float` | Confidence threshold. | `0.5` |
| `iou_thres` | `float` | Intersection over union threshold. | `0.45` |
| `classes` | `list | None` | For filtering by classes. | `None` |
| `num_classes` | `int` | Number of classes. | `1` |
| `agnostic` | `bool` | Runs NMS on all boxes together rather than per class if True. | `False` |
| `multi_label` | `bool` | Multilabel classification. | `False` |
| `max_det` | `int` | Limiting detections. | `300` |
| `max_time_img` | `float` | Maximum time for processing an image. | `0.05` |
| `max_nms` | `int` | Maximum number of boxes. | `30000` |
| `max_wh` | `int` | Maximum width and height. | `7680` |
| `kpts_mode` | `bool` | Keypoints mode. | `False` |
| `det_mode` | `bool` | Detection only mode. If True, the output will only contain bbox detections. | `False` |

Returns

| Type | Description |
| --- | --- |
| `list[np.ndarray]` | An array of detections. If det_mode is False, the detections may include kpts or segmentation outputs. |

### function `parse_kpts`

```python
def parse_kpts(
    kpts: np.ndarray,
    n_keypoints: int,
    img_shape: tuple[int, int],
) -> list[tuple[float, float, float]]
```

Parse keypoints.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `kpts` | `np.ndarray` | Result keypoints. | required |
| `n_keypoints` | `int` | Number of keypoints. | required |
| `img_shape` | `tuple[int, int]` | Image shape of the model input in (height, width) format. | required |

Returns

| Type | Description |
| --- | --- |
| `list[tuple[float, float, float]]` | Parsed keypoints. |

### function `parse_yolo_output`

```python
def parse_yolo_output(
    out: np.ndarray,
    stride: int,
    num_outputs: int,
    anchors: np.ndarray | None = None,
    head_id: int = -1,
    kpts: np.ndarray | None = None,
    det_mode: bool = False,
    subtype: YOLOSubtype = YOLOSubtype.DEFAULT,
) -> np.ndarray
```

Parse a single channel output of an YOLO model.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `out` | `np.ndarray` | A single output of an YOLO model for the given channel. | required |
| `stride` | `int` | Stride. | required |
| `num_outputs` | `int` | Number of outputs of the model. | required |
| `anchors` | `np.ndarray | None` | Anchors for the given head. | `None` |
| `head_id` | `int` | Head ID. | `-1` |
| `kpts` | `np.ndarray | None` | A single output of keypoints for the given channel. | `None` |
| `det_mode` | `bool` | Detection only mode. | `False` |
| `subtype` | `YOLOSubtype` | YOLO version. | `YOLOSubtype.DEFAULT` |

Returns

| Type | Description |
| --- | --- |
| `np.ndarray` | Parsed output. |

### function `resolve_yolo_strides`

```python
def resolve_yolo_strides(
    strides: list[int] | tuple[int, ...] | None,
    subtype: YOLOSubtype,
    num_outputs: int,
) -> list[int]
```

Resolve YOLO strides from metadata or default fallback.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `strides` | `list[int] | tuple[int, ...] | None` | Optional strides from NNArchive head metadata. | required |
| `subtype` | `YOLOSubtype` | YOLO subtype. | required |
| `num_outputs` | `int` | Number of YOLO output heads. | required |

Returns

| Type | Description |
| --- | --- |
| `list[int]` | Resolved YOLO strides. |

## Module Attributes

| Name | Description |
| --- | --- |
| [`logger`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/utils/yolo.md#yolo-Module-Attributes-logger) |  |

### variable `logger`

```python
logger = get_logger(__name__)
```
