# yolo

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

## Classes

| Name | Description |
| --- | --- |
| [`YOLOComputeInputs`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/yolo.md#yolo-Classes-YOLOComputeInputs) | Immutable configuration and tensor bundle for YOLO decoding. |
| [`YOLOExtendedParser`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/yolo.md#yolo-Classes-YOLOExtendedParser) | Parser class for parsing the output of the YOLO Instance Segmentation and Pose Estimation models. |

### class `YOLOComputeInputs`

```python
class YOLOComputeInputs
```

Immutable configuration and tensor bundle for YOLO decoding.

Created by `YOLOExtendedParser.extract()` and consumed by `compute()`. Fields correspond to arguments of
[depthai_nodes.node.parsers.utils.yolo.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).
Optional pose and mask fields are populated only for the selected model mode. Array contents remain mutable even though the
dataclass fields cannot be reassigned.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `anchors` | `list[list[list[float]]] | np.ndarray | None` |  |
| `conf_threshold` | `float` |  |
| `input_shape` | `tuple[int, int] | None` |  |
| `iou_threshold` | `float` |  |
| `keypoint_edges` | `list[tuple[int, int]] | None` |  |
| `keypoint_label_names` | `list[str] | None` |  |
| `kpts_outputs` | `list[np.ndarray] | None` |  |
| `label_names` | `list[str] | None` |  |
| `layer_names` | `list[str]` |  |
| `mask_conf` | `float` |  |
| `masks_outputs_values` | `list[np.ndarray] | None` |  |
| `max_det` | `int` |  |
| `n_classes` | `int` |  |
| `n_keypoints` | `int` |  |
| `outputs_values` | `list[np.ndarray]` |  |
| `protos_len` | `int | None` |  |
| `protos_output` | `np.ndarray | None` |  |
| `strides` | `list[int] | None` |  |
| `subtype` | `YOLOSubtype` |  |
| `v26_mask_coeffs` | `np.ndarray | None` |  |
| `v26_pose_kpts` | `np.ndarray | None` |  |
| `v26_protos` | `np.ndarray | None` |  |

### class `YOLOExtendedParser`

```python
class YOLOExtendedParser(BaseParser)
```

Parser class for parsing the output of the YOLO Instance Segmentation and Pose Estimation models.

> **Note**
> Emits `dai.ImgDetections` messages. dai.ImgDetections message containing bounding boxes, labels, label names, confidence scores, and keypoints or masks and protos of the detected objects.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `anchors` |  | Anchors for the YOLO model (optional). |
| `conf_threshold` |  | Confidence score threshold for detected objects. |
| `input_shape` |  |  |
| `iou_threshold` |  | Intersection over union threshold. |
| `keypoint_edges` |  | Pairs of keypoint indexes defining skeleton edges. For example, `[(0, 1), (1, 2)]` connects keypoint 0 to 1 and 1 to 2. |
| `keypoint_label_names` |  | Labels for the keypoints. |
| `label_names` |  | Names of the classes. |
| `mask_conf` |  | Mask confidence threshold. |
| `max_det` |  |  |
| `n_classes` |  | Number of classes in the model. |
| `n_keypoints` |  | Number of keypoints in the model. |
| `n_prototypes` |  |  |
| `output_layer_names` |  |  |
| `strides` | `list[int] | tuple[int, ...] | None` | Strides for the YOLO output heads. |
| `subtype` |  | Version of the YOLO model. |

Methods

| Name | Description |
| --- | --- |
| [`__init__`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/yolo.md#yolo-Classes-YOLOExtendedParser-__init__) | Initialize the parser node. |
| [`build`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/yolo.md#yolo-Classes-YOLOExtendedParser-build) | Configures the parser. |
| [`compute`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/yolo.md#yolo-Classes-YOLOExtendedParser-compute) | Decode a prepared YOLO input bundle. |
| [`emit`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/yolo.md#yolo-Classes-YOLOExtendedParser-emit) | Create a `dai.ImgDetections` message and send it on `out`. |
| [`extract`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/yolo.md#yolo-Classes-YOLOExtendedParser-extract) | Select and dequantize the model tensors needed for parsing. |
| [`run`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/yolo.md#yolo-Classes-YOLOExtendedParser-run) | Read queued network outputs, parse them, and emit results while running. |
| [`setAnchors`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/yolo.md#yolo-Classes-YOLOExtendedParser-setAnchors) | Sets the anchors for the YOLO model. |
| [`setConfidenceThreshold`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/yolo.md#yolo-Classes-YOLOExtendedParser-setConfidenceThreshold) | Sets the confidence score threshold for detected objects. |
| [`setIouThreshold`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/yolo.md#yolo-Classes-YOLOExtendedParser-setIouThreshold) | Sets the intersection over union threshold. |
| [`setKeypointEdges`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/yolo.md#yolo-Classes-YOLOExtendedParser-setKeypointEdges) | Sets the edges for the keypoints. |
| [`setKeypointLabelNames`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/yolo.md#yolo-Classes-YOLOExtendedParser-setKeypointLabelNames) | Sets the label names for the keypoints. |
| [`setLabelNames`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/yolo.md#yolo-Classes-YOLOExtendedParser-setLabelNames) | Sets the names of the classes. |
| [`setMaskConfidence`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/yolo.md#yolo-Classes-YOLOExtendedParser-setMaskConfidence) | Sets the mask confidence threshold. |
| [`setNumClasses`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/yolo.md#yolo-Classes-YOLOExtendedParser-setNumClasses) | Sets the number of classes in the model. |
| [`setNumKeypoints`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/yolo.md#yolo-Classes-YOLOExtendedParser-setNumKeypoints) | Sets the number of keypoints in the model. |
| [`setOutputLayerNames`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/yolo.md#yolo-Classes-YOLOExtendedParser-setOutputLayerNames) | Sets the output layer names for the parser. |
| [`setStrides`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/yolo.md#yolo-Classes-YOLOExtendedParser-setStrides) | Sets the strides for YOLO output heads. |
| [`setSubtype`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/yolo.md#yolo-Classes-YOLOExtendedParser-setSubtype) | Sets the subtype of the YOLO model. |

#### method `__init__`

```python
def __init__(
    conf_threshold: float = 0.5,
    n_classes: int = 1,
    label_names: list[str] | None = None,
    iou_threshold: float = 0.5,
    mask_conf: float = 0.5,
    n_keypoints: int = 17,
    max_det: int = 300,
    anchors: list[list[list[float]]] | None = None,
    subtype: str = '',
    keypoint_label_names: list[str] | None = None,
    keypoint_edges: list[tuple[int, int]] | None = None,
)
```

Initialize the parser node.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `conf_threshold` | `float` | The confidence threshold for the detections | `0.5` |
| `n_classes` | `int` | The number of classes in the model | `1` |
| `label_names` | `list[str] | None` | The names of the classes | `None` |
| `iou_threshold` | `float` | The intersection over union threshold | `0.5` |
| `mask_conf` | `float` | The mask confidence threshold | `0.5` |
| `n_keypoints` | `int` | The number of keypoints in the model | `17` |
| `max_det` | `int` | Maximum number of detections to retain. | `300` |
| `anchors` | `list[list[list[float]]] | None` | The anchors for the YOLO model | `None` |
| `subtype` | `str` | The version of the YOLO model | `''` |
| `keypoint_label_names` | `list[str] | None` | The labels for the keypoints | `None` |
| `keypoint_edges` | `list[tuple[int, int]] | None` | Connection pairs of the keypoints. Example: [(0,1), (1,2), (2,3), (3,0)] shows that keypoint 0 is connected to keypoint 1, keypoint 1 is connected to keypoint 2, etc. | `None` |

#### method `build`

```python
def build(head_config: dict[str, Any])
```

Configures the parser.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `head_config` | `dict[str, Any]` | The head configuration for the parser. | required |

Returns

| Type | Description |
| --- | --- |
| `YOLOExtendedParser` | The parser object with the head configuration set. |

#### static method `compute`

```python
def compute(inputs: YOLOComputeInputs) -> dict[str, Any]
```

Decode a prepared YOLO input bundle.

> **Note**
> Uses [depthai_nodes.node.parsers.utils.yolo.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) for decoding and validation.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `inputs` | `YOLOComputeInputs` | Tensor and configuration bundle returned by `extract()`. | required |

Returns

| Type | Description |
| --- | --- |
| `dict[str, Any]` | 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. |

#### method `emit`

```python
def emit(output: dai.NNData, payload: dict[str, Any])
```

Create a `dai.ImgDetections` message and send it on `out`.

Copies source timestamps and sequence number, and carries the source image transformation when present.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `output` | `dai.NNData` | Neural network output carrying tensors and source timestamps, sequence number, and optional image transformation. | required |
| `payload` | `dict[str, Any]` | Dictionary returned by `compute()` with the mode-specific boxes, scores, labels, keypoints, and masks. | required |

#### method `extract`

```python
def extract(output: dai.NNData) -> YOLOComputeInputs
```

Select and dequantize the model tensors needed for parsing.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `output` | `dai.NNData` | Neural network output carrying tensors and source timestamps, sequence number, and optional image transformation. | required |

Returns

| Type | Description |
| --- | --- |
| `YOLOComputeInputs` | A `YOLOComputeInputs` bundle with dequantized tensors, resolved image geometry, strides, and current parser settings. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If YOLO26 has no configured input shape, or head strides cannot be resolved. |

#### method `run`

```python
def run()
```

Read queued network outputs, parse them, and emit results while running.

The pipeline invokes this processing loop. It exits when the input queue closes or the node stops.

#### method `setAnchors`

```python
def setAnchors(anchors: list[list[list[float]]])
```

Sets the anchors for the YOLO model.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `anchors` | `list[list[list[float]]]` | The anchors for the YOLO model. | required |

#### method `setConfidenceThreshold`

```python
def setConfidenceThreshold(threshold: float)
```

Sets the confidence score threshold for detected objects.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `threshold` | `float` | Confidence score threshold for detected objects. | required |

#### method `setIouThreshold`

```python
def setIouThreshold(iou_threshold: float)
```

Sets the intersection over union threshold.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `iou_threshold` | `float` | The intersection over union threshold. | required |

#### method `setKeypointEdges`

```python
def setKeypointEdges(keypoint_edges: list[tuple[int, int]])
```

Sets the edges for the keypoints.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `keypoint_edges` | `list[tuple[int, int]]` | The edges for the keypoints. | required |

#### method `setKeypointLabelNames`

```python
def setKeypointLabelNames(keypoint_label_names: list[str])
```

Sets the label names for the keypoints.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `keypoint_label_names` | `list[str]` | The labels for the keypoints. | required |

#### method `setLabelNames`

```python
def setLabelNames(label_names: list[str])
```

Sets the names of the classes.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `label_names` | `list[str]` | The names of the classes. | required |

#### method `setMaskConfidence`

```python
def setMaskConfidence(mask_conf: float)
```

Sets the mask confidence threshold.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `mask_conf` | `float` | The mask confidence threshold. | required |

#### method `setNumClasses`

```python
def setNumClasses(n_classes: int)
```

Sets the number of classes in the model.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `n_classes` | `int` | The number of classes in the model. | required |

#### method `setNumKeypoints`

```python
def setNumKeypoints(n_keypoints: int)
```

Sets the number of keypoints in the model.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `n_keypoints` | `int` | The number of keypoints in the model. | required |

#### method `setOutputLayerNames`

```python
def setOutputLayerNames(output_layer_names: list[str])
```

Sets the output layer names for the parser.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `output_layer_names` | `list[str]` | The output layer names for the parser. | required |

#### method `setStrides`

```python
def setStrides(strides: list[int] | tuple[int, ...])
```

Sets the strides for YOLO output heads.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `strides` | `list[int] | tuple[int, ...]` | Strides for YOLO output heads. | required |

#### method `setSubtype`

```python
def setSubtype(subtype: str)
```

Sets the subtype of the YOLO model.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `subtype` | `str` | The subtype of the YOLO model. | required |
