# instance_to_semantic_mask

Python API: `depthai_nodes.node.instance_to_semantic_mask`

## Classes

| Name | Description |
| --- | --- |
| [`InstanceToSemanticMask`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/instance_to_semantic_mask.md#instance_to_semantic_mask-Classes-InstanceToSemanticMask) | Replace instance-mask IDs with detection class labels. |

### class `InstanceToSemanticMask`

```python
class InstanceToSemanticMask(BaseHostNode)
```

Replace instance-mask IDs with detection class labels.

The input and output are `dai.ImgDetections` messages. A copied message is emitted; its mask is replaced when both a mask and
detections are present. Class labels must be representable in uint8, with 255 reserved for background. Missing or empty masks pass
through on the copied message unchanged.

Methods

| Name | Description |
| --- | --- |
| [`__init__`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/instance_to_semantic_mask.md#instance_to_semantic_mask-Classes-InstanceToSemanticMask-__init__) | Initialize logging and the platform-specific output image format. |
| [`build`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/instance_to_semantic_mask.md#instance_to_semantic_mask-Classes-InstanceToSemanticMask-build) | Connect a detection stream with instance masks. |
| [`process`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/instance_to_semantic_mask.md#instance_to_semantic_mask-Classes-InstanceToSemanticMask-process) | Copy detections and convert valid mask indexes to class labels. |

#### method `__init__`

```python
def __init__()
```

Initialize logging and the platform-specific output image format.

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If the pipeline device platform has no configured image-frame format. |

#### method `build`

```python
def build(detections: dai.Node.Output) -> InstanceToSemanticMask
```

Connect a detection stream with instance masks.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `detections` | `dai.Node.Output` | Output producing `dai.ImgDetections`. | required |

Returns

| Type | Description |
| --- | --- |
| `InstanceToSemanticMask` | This node. |

#### method `process`

```python
def process(msg: dai.Buffer)
```

Copy detections and convert valid mask indexes to class labels.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `msg` | `dai.Buffer` | Detections with a mask of non-negative instance indexes. Values of 255 or indexes beyond the detection list become background. | required |

Raises

| Type | Description |
| --- | --- |
| `TypeError` | If the input is not `dai.ImgDetections`. |
