# extended_neural_network

Python API: `depthai_nodes.node.extended_neural_network`

## Classes

### ExtendedNeuralNetwork

A high-level host node that performs neural network inference with automatic input resizing and optional coordinate remapping.

`ExtendedNeuralNetwork` is a convenience wrapper around an internal `ParsingNeuralNetwork` node. It handles:

 * Model loading from HubAI slug, `dai.NNModelDescription`, or `dai.NNArchive`.
 * Automatic input resizing to match the neural network input resolution.
 * Optional coordinate remapping when the input is not a camera node.

Two input modes are supported:

 * Camera input: When `inputImage` is a `dai.node.Camera`, the node requests a resized output directly from the camera using the
   appropriate hardware resize mode. In this case, the neural network outputs are already aligned with the original image
   coordinates and no additional mapping is required.
 * Generic stream input: When `inputImage` is a `dai.Node.Output`, an internal `dai.node.ImageManip` node resizes frames to the
   network's expected input size. A `CoordinatesMapper` node is then inserted to map neural network outputs back to the original
   image coordinate space.

The node exposes neural network outputs via `out`, and passthrough frames via `passthrough`.

> **Note**
> * This node is currently not supported on the RVC2 platform.
 * When a non-camera input is used, an additional ImageManip node is inserted into the pipeline.
 * Coordinate remapping is performed automatically when resizing occurs outside of a camera node.

Outputs:

 * `out : dai.Node.Output`: Parsed neural network output stream. If coordinate remapping is required, this stream contains
   remapped results.
 * `outputs : dai.Node.Output`: Alias for `out` or the raw neural network outputs, depending on input mode.
 * `passthrough : dai.Node.Output`: Passthrough stream from the underlying neural network node.

See also:

 * `ParsingNeuralNetwork`: Node responsible for running inference and parsing results.
 * `CoordinatesMapper`: Node used to remap output coordinates when resizing is applied.
 * `dai.node.ImageManip`: Node used for resizing when input is not a camera node.

#### Methods

##### init

```python
def __init__(self):
```

Initialize logging and the platform-specific output image format.

Raises

 * `ValueError`: If the pipeline device platform has no configured image-frame format.

##### build

```python
def build(inputImage: dai.node.Camera | dai.Node.Output, nnSource: dai.NNModelDescription | dai.NNArchive | str, resizeMode: dai.ImageManipConfig.ResizeMode = dai.ImageManipConfig.ResizeMode.CENTER_CROP) -> ExtendedNeuralNetwork:
```

Build the internal inference pipeline.

Parameters

 * `inputImage` (`dai.node.Camera | dai.Node.Output`): Source of input frames. Camera nodes are resized on-device by the camera;
   generic outputs are resized via an internal ImageManip.
 * `nnSource` (`dai.NNModelDescription | dai.NNArchive | str`): HubAI model slug, dai.NNModelDescription, or dai.NNArchive.
 * `resizeMode` (`dai.ImageManipConfig.ResizeMode`): Resize strategy used when adapting frames to the network input shape.

Returns

 * `ExtendedNeuralNetwork`: The configured node instance.

Raises

 * `ValueError`: If `nnSource` is not an archive, model description, or Model Zoo slug.

##### run

```python
def run(self):
```

No-op required by `BaseThreadedHostNode`.

#### Attributes

##### out

Return the primary parsed output stream.

##### outputs

Return the multi-head output stream when available.

##### passthrough

Return the passthrough stream from the underlying NN node.
