oakutils.blobs package
Subpackages
- oakutils.blobs.definitions package
- Subpackages
- Submodules
- oakutils.blobs.definitions.abstract_model module
- oakutils.blobs.definitions.closing module
- oakutils.blobs.definitions.dilation module
- oakutils.blobs.definitions.erosion module
- oakutils.blobs.definitions.gaussian module
- oakutils.blobs.definitions.gftt module
- oakutils.blobs.definitions.harris module
- oakutils.blobs.definitions.hessian module
- oakutils.blobs.definitions.laplacian module
- oakutils.blobs.definitions.laserscan module
- oakutils.blobs.definitions.opening module
- oakutils.blobs.definitions.point_cloud module
- oakutils.blobs.definitions.sobel module
- Module contents
- oakutils.blobs.models package
Module contents
Module for compiling, running, and creating custom models.
Note:
This module requires the [compiler] dependencies to be installed. If not only the models submodule will be available.
Submodules
- definitions
Contains the definitions for the models.
- models
Contains the pre-compiled models.
Classes
- BenchmarkData
Dataclass for storing benchmark data.
- Metric
Dataclass for storing metrics.
Functions
- bencmark_blob
Benchmark a blob.
- compile_model
Compiles a model.
- compile_onnx
Compiles an onnx model into a blob.
- clear_cache
Clears the cache of compiled blobs.
- get_blob
Load a blob from a path.
- get_cache_dir
Get the cache directory path.
- get_input_layer_data
Get the input layer data for a blob.
- get_output_layer_data
Get the output layer data for a blob.
- get_layer_data
Get the input and output layer data for a blob.
- get_model_name
Get the name of a compiled model file.
- get_model_path
Get the path to the model blob.
- oakutils.blobs.benchmark_blob(blob: Path | str, iterations: int = 100, warmup_iterations: int = 10, *, is_yolo: bool | None = None, warmup: bool | None = None) BenchmarkData
Benchmark a blob.
- Parameters:
blob (Path | str) – The path to the blob file or directory containing the blob files.
iterations (int, optional) – The number of iterations to run, by default 100
warmup_iterations (int, optional) – The number of warmup iterations to run, by default 10
is_yolo (bool, optional) – Whether the blob is a Yolo blob, by default None. If is_yolo is True, then the blob_path should be a directory and the directory should contain a .json file generated during compilation of the blob.
warmup (bool, optional) – Whether to run warmup iterations, by default None. If warmup is True, then the warmup_iterations will be run before the iterations.
- Returns:
The benchmark data.
- Return type:
- Raises:
FileNotFoundError – If the blob file or directory does not exist.
ValueError – If is_yolo is True and the blob_path is not a directory.
ValueError – If the directory does not contain exactly one blob file.
ValueError – If the directory does not contain exactly one json file.
- oakutils.blobs.get_blob(blob_path: Path | str) Blob
Load a blob from a file.
- Parameters:
blob_path (Path | str) – The path to the blob.
- Returns:
The blob object.
- Return type:
dai.OpenVINO.Blob
- Raises:
FileNotFoundError – If the blob does not exist.
- oakutils.blobs.get_input_layer_data(blob: Path | str | Blob) list[LayerData]
Get the input layer data for a blob.
- oakutils.blobs.get_layer_data(blob: Path | str | Blob) tuple[list[LayerData], list[LayerData]]
Get the input and output layer data for a blob.
- oakutils.blobs.get_model_path(model_type: str, model_attributes: list[str], shaves: int) Path
Get the path to the model blob.
- Parameters:
model_type (str) – The model type to get the path for. Examples include: [‘gaussian’, ‘sobel’]
model_attributes (list[str]) – The model attributes to get the path for. An example could be [‘15’] for a gaussian model using a 15x15 kernel size.
shaves (int) – The number of shaves the model was compiled for.
- Returns:
The path to the model blob.
- Return type:
Path
- Raises:
FileNotFoundError – If the returned model blob does not exists.
ValueError – If no model blob paths could be formed from the attributes and shaves.