oakutils.vpu package

Module contents

Submodule for using the onboard VPU as a standalone processor.

Classes

VPU

A class for using the onboard VPU as a standalone processor.

class oakutils.vpu.VPU(device_id: str | None = None)

Bases: object

Class for using the onboard VPU as a standalone processor.

reconfigure(blob_path: str | Path, input_names: list[str] | None = None, model_data: YolomodelData | MobilenetData | None = None) None

Use to reconfigure the VPU with a single new blob file.

Parameters:
  • blob_path (str | Path) – The path to the blob file.

  • input_names (list[str], optional) – The names of the input layers. Defaults to None.

  • model_data (YolomodelData | MobilenetData, optional) – The model data. Defaults to None. Can be used to set the YoloModelData or MobilenetData. If None, then a generic neural network will be created.

reconfigure_multi(blob_paths: Sequence[str | Path], input_names: Sequence[list[str] | None] | None = None, modeldata: Sequence[YolomodelData | MobilenetData | None] | None = None) None

Reconfigure the VPU with multiple blob files.

Parameters:
  • blob_paths (Sequence[str | Path]) – The paths to the blob files.

  • input_names (Sequence[list[str] | None]) – The names of the input layers. Defaults to None. Should be filled in if a model has multiple inputs.

  • modeldata (Sequence[YolomodelData | MobilenetData | None]) – The model data. Defaults to None. Should be filled in if the model is a YOLO or Mobilenet model. If None, then a generic neural network will be created.

run(data: np.ndarray | list[np.ndarray] | list[np.ndarray | list[np.ndarray]], *, safe: bool | None = None) dai.ADatatype | list[dai.ADatatype] | list[dai.ADatatype | list[dai.ADatatype]]

Use to run an inference on the VPU.

If the VPU was configured with multiple networks, then data must be a list of data. If the VPU was configured with a single network, then data can be a single np.ndarray or a list of np.ndarray if the network has multiple inputs. The return type will change based on whether the VPU was configured with multiple networks. If configured with a single network, then the return will be a single np.ndarray or dai.ImgDetections. If configured with multiple networks, then the return will be a list of np.ndarray or dai.ImgDetections.

Parameters:
  • data (np.ndarray | list[np.ndarray]) – The data to run an inference on.

  • safe (bool, optional) – If True, will evaluate the data before sending to the VPU. If False, will send data directly to the VPU. By default None, which will use safe mode.

Returns:

The result of the inference.

Return type:

dai.ADatatype | list[dai.ADatatype] | list[dai.ADatatype | list[dai.ADatatype]]

Raises:

RuntimeError – If the VPU thread is not set or alive. Will occur if not configured. If the VPU result is None.

stop() None

Use to stop the VPU.