ON THIS PAGE

  • API reference

API reference

0.8.0
package

luxonis_ml

package
package
module
package
package
module
package
variable
package

luxonis_ml.data

package
package
package
package
package
class
BucketStorage
Underlying object storage for a bucket.
class
BucketType
Whether bucket storage is internal to Luxonis or not.
class
ImageType
Image type for IMAGE HType.
class
MediaType
Individual file type.
function
load_dataset_plugins()
Registers any external dataset BaseDataset class plugins.
function
load_loader_plugins()
Registers any external dataset BaseLoader class plugins.
package

luxonis_ml.data.augmentations

module
module
module
module
package
module
class
AlbumentationsEngine
Augmentation engine using the Albumentations library under the hood.  Configuration Format  The configuration is a list of dictionaries, where the dictionaries contain the name of the transformation and optionally its parameters. It can also contain a boolean flag use_for_resizing that indicates whether the transformation should be used for resizing. If no resizing augmentation is provided, the engine will use either A.Resize or LetterboxResize depending on the keep_aspect_ratio parameter.  The name must be either a valid name of an Albumentations transformation (accessible under the albumentations namespace), or a name of a custom transformation registered in the TRANSFORMATIONS registry.  Example:      [         {             "name": "Affine",             "params": {                 "rotate": 30,                 "scale": 0.5,                 "p": 0.3,             },         },         {             "name": "MixUp",             "params": {                 "alpha": [0.3, 0.7],                 "p": 0.5,             },         },         {             "name": "CustomResize",             "use_for_resizing": True,         },     ]  Transformation Order  The order of transformations provided in the configuration is not guaranteed to be preserved. The transformations are divided into the following groups and are applied in the same order:  batch transformations: Subclasses of BatchTransform.  spatial transformations: Subclasses of `A.DualTransform`.  custom transformations: Subclasses of `A.BasicTransform`, but not subclasses of more specific base classes above.  pixel transformations: Subclasses of `A.ImageOnlyTransform`. These transformations act only on the image.  Supported Augmentations  Official Augmentations  All augmentations provided by the Albumentations library are supported.  Supported Batch Augmentations  MixUp  MixUp is a data augmentation technique that blends 2 source images into a single image using a weight coefficient alpha.  Mosaic4  Mosaic4 transformation combines 4 images into a single image by placing them in a 2x2 grid.  Augmenting Unsupported Tasks  Albumentations do not natively support all the tasks supported by Luxonis Data Format. This sections describes how unsupported tasks are handled.  Note that the following applies only to officially supported augmentations. Custom augmentations can be implemented to handle arbitrary tasks.  Classification  Classification tasks can be properly augmented only for multi-label tasks, where each class is tied to a bounding box. In such cases, the classes belonging to bboxes falling outside the image are removed. In other cases, the classification annotation is kept as is.  Metadata  Metadata tasks can contain arbitrary data and their semantics are unknown to the augmentation engine. Therefore, the only transformation applied to metadata is discarding metadata associated with boxes falling outside the image.  Arrays  Arrays are dealt with in the same way as metadata. The only transformation applied to arrays is discarding arrays associated with bboxes falling outside the image.  Oriented Bounding Boxes  (Not yet implemented)  Oriented bounding boxes are of shape (n_boxes, 5) where the last dimension contains the angle of the box. This format is not supported by Albumentations, however, Albumentations support angle to be part of the keypoints. So, the oriented bounding boxes are split into regular bounding boxes and a set of keypoints that represent the center of the bbox and contain the angle as the third coordinate.  Both the keypoints and the bboxes are augmented separately. At the end, the angle is extracted from the keypoints and added back to the bounding boxes. The keypoints are discarded.  Custom Augmentations  Custom augmentations can be implemented by creating a subclass of A.BasicTransform and registering it in the TRANSFORMATIONS registry.  Possible target types that the augmentation can receive are:  'image': The image. All augmentations should usually support this target. For subclasses of A.ImageOnlyTransform or A.DualTransform this means overriding the apply method.  'bboxes': Bounding boxes. For subclasses of A.DualTransform, this means overriding the apply_to_bboxes method.  'keypoints': Keypoints. For subclasses of A.DualTransform, this means overriding the apply_to_keypoints method.  'mask': Segmentation masks. For subclasses of A.DualTransform, this means overriding the apply_to_mask method.  'instance_mask': Instance segmentation masks. For subclasses of BatchTransform, this means overriding the apply_to_instance_mask method.  Subclasses of A.DualTransform do not support this target, instance masks are treated as regular masks instead.  Custom augmentations can support instance masks by implementing their own logic for handling them and overriding the targets property to include the instance_mask target.  'array': Arbitrary arrays. Can only be supported by custom augmentations by implementing their own logic and adding the array target to the targets property.  'metadata': Metadata labels. Same situation as with the 'array' type.  'classification': One-hot encoded multi-task classification labels. Same situation as with the 'array' type.  Example:      class CustomArrayAugmentation(A.BasicTransform):          @property         @override         def targets(self) -> Dict[str, Any]:             return {                 "image": self.apply,                 "array": self.apply_to_array,             }          def apply(self, image: np.ndarray, **kwargs) -> np.ndarray:             ...          def apply_to_array(             self, array: np.ndarray, **kwargs         ) -> np.ndarray:             ...
constant
class
class
class

luxonis_ml.data.augmentations.albumentations_engine.AlbumentationConfigItem(luxonis_ml.typing.ConfigItem)

module

luxonis_ml.data.augmentations.custom.mosaic

function
function
function
apply_mosaic4_to_images(image_batch: list [ np.ndarray ], out_height: int, out_width: int, x_crop: int, y_crop: int, padding: float | list [ int ] | list [ float ] | None = None) -> np.ndarray: np.ndarray
Arrange the images in a 2x2 grid layout.  The input images should have the same number of channels but can have different widths and heights. The gaps are filled by the padding value.
function
apply_mosaic4_to_bboxes(bbox: np.ndarray, in_height: int, in_width: int, position_index: int, out_height: int, out_width: int, x_crop: int, y_crop: int) -> np.ndarray: np.ndarray
Adjust bounding box coordinates to account for mosaic grid position.  This function modifies bounding boxes according to their placement in a 2x2 grid mosaic, shifting their coordinates based on the tile's relative position within the mosaic.
function
apply_mosaic4_to_keypoints(keypoints: np.ndarray, in_height: int, in_width: int, position_index: int, out_height: int, out_width: int, x_crop: int, y_crop: int) -> np.ndarray: np.ndarray
Adjust keypoint coordinates based on mosaic grid position.  This function adjusts the keypoint coordinates by placing them in one of the 2x2 mosaic grid cells, with shifts relative to the mosaic center.
class

luxonis_ml.data.augmentations.custom.LetterboxResize(albumentations.DualTransform)

variable
method
__init__(self, height: int, width: int, interpolation: int = cv2.INTER_LINEAR, image_fill_value: Color = 'black', mask_fill_value: int = 0, p: float = 1.0)
Augmentation to apply letterbox resizing to images. Also transforms masks, bboxes and keypoints to correct shape.  @type height: int @param height: Desired height of the output. @type width: int @param width: Desired width of the output. @type interpolation: int @param interpolation: cv2 flag to specify interpolation used     when resizing. Defaults to C{cv2.INTER_LINEAR}. @type image_fill_value: int @param image_fill_value: Padding value for images. Defaults to     "black". @type mask_fill_value: int @param mask_fill_value: Padding value for masks. Must be an     integer representing the class label. Defaults to C{0}     (background class). @type p: float @param p: Probability of applying the transform. Defaults to     C{1.0}.
variable
variable
variable
variable
property
method
get_params_dependent_on_data(self, params: dict [ str , Any ], data: dict [ str , Any ]) -> dict[str, Any]: dict[str, Any]
Updates augmentation parameters with the necessary metadata.  @param params: The existing augmentation parameters dictionary. @type params: Dict[str, Any] @param data: The data dictionary. @type data: Dict[str, Any] @return: Additional parameters for the augmentation. @rtype: Dict[str, Any]
static method
LetterboxResize.compute_padding(orig_height: int, orig_width: int, out_height: int, out_width: int) -> tuple[int, int, int, int]: tuple[int, int, int, int]
Computes the padding required to resize an image to a letterbox format.  @type orig_height: int @param orig_height: Original height of the image. @type orig_width: int @param orig_width: Original width of the image. @type out_height: int @param out_height: Desired height of the output. @type out_width: int @param out_width: Desired width of the output. @rtype: Tuple[int, int, int, int] @return: Padding values for the top, bottom, left and right     sides of the image.
method
apply(self, img: np.ndarray, pad_top: int, pad_bottom: int, pad_left: int, pad_right: int, _) -> np.ndarray: np.ndarray
Applies the letterbox augmentation to an image.  @type img: np.ndarray @param img: Input image to which resize is applied. @type pad_top: int @param pad_top: Number of pixels to pad at the top. @type pad_bottom: int @param pad_bottom: Number of pixels to pad at the bottom. @type pad_left: int @param pad_left: Number of pixels to pad on the left. @type pad_right: int @param pad_right: Number of pixels to pad on the right. @rtype: np.ndarray @return: Image with applied letterbox resize.
method
method
method
class

luxonis_ml.data.augmentations.custom.MixUp(luxonis_ml.data.augmentations.batch_transform.BatchTransform)

method
__init__(self, alpha: float | tuple [ float , float ] = 0.5, keep_aspect_ratio: bool = True, p: float = 0.5)
MixUp augmentation that merges two images and their annotations into one. If images are not of same size then second one is first resized to match the first one.  @type alpha: Union[float, Tuple[float, float]] @param alpha: Mixing coefficient, either a single float or a     tuple representing the range. Defaults to C{0.5}. @type keep_aspect_ratio: bool @param keep_aspect_ratio: Whether to keep the aspect ratio of     the second image when resizing. Defaults to C{True}. @type p: float, optional @param p: Probability of applying the transform. Defaults to     C{0.5}.
variable
variable
method
apply(self, image_batch: list [ np.ndarray ], image_shapes: list [ tuple [ int , int ] ], alpha: float, _) -> np.ndarray: np.ndarray
Applies the transformation to a batch of images.  @type image_batch: List[np.ndarray] @param image_batch: Batch of input images to which the     transformation is applied. @type image_shapes: List[Tuple[int, int]] @param image_shapes: Shapes of the input images in the batch. @rtype: List[np.ndarray] @return: List of transformed images.
method
apply_to_mask(self, mask_batch: list [ np.ndarray ], image_shapes: list [ tuple [ int , int ] ], alpha: float, _) -> np.ndarray: np.ndarray
Applies the transformation to a batch of masks.  Blends masks together. In case of a conflict, the class from the mask associated with higher alpha is chosen.  @type mask_batch: List[np.ndarray] @param mask_batch: Batch of input masks to which the     transformation is applied. @type image_shapes: List[Tuple[int, int]] @param image_shapes: Shapes of the input images in the batch. @type alpha: float @param alpha: Mixing coefficient. @rtype: List[np.ndarray] @return: List of transformed masks.
method
apply_to_instance_mask(self, mask_batch: list [ np.ndarray ], image_shapes: list [ tuple [ int , int ] ], _) -> np.ndarray: np.ndarray
Applies the transformation to a batch of instance masks.  @type masks_batch: List[np.ndarray] @param masks_batch: Batch of input instance masks to which the     transformation is applied. @rtype: np.ndarray @return: Transformed instance masks.
method
apply_to_bboxes(self, bboxes_batch: list [ np.ndarray ], image_shapes: list [ tuple [ int , int ] ], _) -> np.ndarray: np.ndarray
Applies the transformation to a batch of bboxes.  @type bboxes_batch: List[np.ndarray] @param bboxes_batch: Batch of input bboxes to which the     transformation is applied. @rtype: np.ndarray @return: Transformed bboxes.
method
apply_to_keypoints(self, keypoints_batch: list [ np.ndarray ], image_shapes: list [ tuple [ int , int ] ], _) -> np.ndarray: np.ndarray
Applies the transformation to a batch of keypoints.  @type keypoints_batch: List[np.ndarray] @param keypoints_batch: Batch of input keypoints to which the     transformation is applied. @rtype: np.ndarray @return: Transformed keypoints.
method
get_params(self) -> dict[str, Any]: dict[str, Any]
Update parameters.  @param params: Dictionary containing parameters. @type params: Dict[str, Any] @return: Dictionary containing updated parameters. @rtype: Dict[str, Any]
method
class

luxonis_ml.data.augmentations.custom.Mosaic4(luxonis_ml.data.augmentations.batch_transform.BatchTransform)

method
__init__(self, out_height: int, out_width: int, value: float | list [ int ] | list [ float ] | None = None, mask_value: float | list [ int ] | list [ float ] | None = None, p: float = 0.5)
Mosaic augmentation arranges selected four images into single image in a 2x2 grid layout. This is done in deterministic way meaning first image in the batch will always be in top left. The input images should have the same number of channels but can have different widths and heights. The output is cropped around the intersection point of the four images with the size (out_with x out_height). If the mosaic image is smaller than width x height, the gap is filled by the C{fill_value}.  @type out_height: int @param out_height: Output image height. The mosaic image is     cropped by this height around the mosaic center. If the size     of the mosaic image is smaller than this value the gap is     filled by the C{value}. @type out_width: int @param out_width: Output image width. The mosaic image is     cropped by this height around the mosaic center. If the size     of the mosaic image is smaller than this value the gap is     filled by the C{value}. @type value: Optional[Union[int, float, list[int], list[float]]] @param value: Padding value. Defaults to C{None}. @type mask_value: Optional[Union[int, float, list[int],     list[float]]] @param mask_value: Padding value for masks. Defaults to C{None}. @type p: float @param p: Probability of applying the transform. Defaults to     C{0.5}.
variable
variable
variable
variable
method
get_params_dependent_on_data(self, params: dict [ str , Any ], data: dict [ str , Any ]) -> dict[str, Any]: dict[str, Any]
Get parameters dependent on the targets.  @param params: Dictionary containing parameters. @type params: dict[str, Any] @param data: Dictionary containing data. @type data: dict[str, Any] @return: Dictionary containing parameters dependent on the     targets. @rtype: dict[str, Any]
method
generate_random_crop_center(self) -> tuple[int, int]: tuple[int, int]
Generate a random crop center within the bounds of the mosaic image size.
method
apply(self, image_batch: list [ np.ndarray ], x_crop: int, y_crop: int, _) -> np.ndarray: np.ndarray
Applies the transformation to a batch of images.  @type image_batch: list[np.ndarray] @param image_batch: Batch of input images to which the     transformation is applied. @type x_crop: int @param x_crop: x-coordinate of the croping start point @type y_crop: int @param y_crop: y-coordinate of the croping start point @rtype: np.ndarray @return: Transformed images.
method
apply_to_mask(self, mask_batch: list [ np.ndarray ], x_crop: int, y_crop: int, out_height: int, out_width: int, _) -> np.ndarray: np.ndarray
Applies the transformation to a batch of masks.  @type mask_batch: list[np.ndarray] @param mask_batch: Batch of input masks to which the     transformation is applied. @type x_crop: int @param x_crop: x-coordinate of the croping start point @type y_crop: int @param y_crop: y-coordinate of the croping start point @rtype: np.ndarray @return: Transformed masks.
method
apply_to_instance_mask(self, masks_batch: list [ np.ndarray ], x_crop: int, y_crop: int, _) -> np.ndarray: np.ndarray
Applies the transformation to a batch of instance masks.  @type mask_batch: list[np.ndarray] @param mask_batch: Batch of input masks to which the     transformation is applied. @type x_crop: int @param x_crop: x-coordinate of the croping start point @type y_crop: int @param y_crop: y-coordinate of the croping start point @rtype: np.ndarray @return: Transformed masks.
method
apply_to_bboxes(self, bboxes_batch: list [ np.ndarray ], image_shapes: list [ tuple [ int , int ] ], x_crop: int, y_crop: int, _) -> np.ndarray: np.ndarray
Applies the transformation to a batch of bboxes.  @type bboxes_batch: list[np.ndarray] @param bboxes_batch: Batch of input bboxes to which the     transformation is applied. @type indices: list[tuple[int, int]] @param indices: Indices of images in the batch. @type image_shapes: list[tuple[int, int]] @param image_shapes: Shapes of the input images in the batch. @type params: Any @param params: Additional parameters for the transformation. @type x_crop: int @param x_crop: x-coordinate of the croping start point @type y_crop: int @param y_crop: y-coordinate of the croping start point @rtype: list[np.ndarray] @return: list of transformed bboxes.
method
apply_to_keypoints(self, keypoints_batch: list [ np.ndarray ], image_shapes: list [ tuple [ int , int ] ], x_crop: int, y_crop: int, _) -> np.ndarray: np.ndarray
Applies the transformation to a batch of keypoints.  @type keypoints_batch: list[KeypointType] @param keypoints_batch: Batch of input keypoints to which the     transformation is applied. @type indices: list[tuple[int, int]] @param indices: Indices of images in the batch. @type image_shapes: list[tuple[int, int]] @param image_shapes: Shapes of the input images in the batch. @type params: Any @param params: Additional parameters for the transformation. @type x_crop: int @param x_crop: x-coordinate of the croping start point @type y_crop: int @param y_crop: y-coordinate of the croping start point @rtype: list[KeypointType] @return: list of transformed keypoints.
class

luxonis_ml.data.augmentations.custom.HorizontalSymetricKeypointsFlip(albumentations.DualTransform)

method
__init__(self, keypoint_pairs: list [ tuple [ int , int ] ], p: float = 0.5)
Augmentation to horizontally flip an image along with bboxes, segmentation masks and symmetric keypoints.  @param keypoint_pairs: List of tuples with indices to swap after     flipping. @param p: Probability of applying the augmentation.
variable
variable
property
method
get_params_dependent_on_data(self, params: dict [ str , Any ], data: dict [ str , Any ]) -> dict[str, Any]: dict[str, Any]
Get parameters dependent on the targets.  @param params: Dictionary containing parameters. @type params: dict[str, Any] @param data: Dictionary containing data. @type data: dict[str, Any]
method
apply(self, img: np.ndarray, params) -> np.ndarray: np.ndarray
Flips the image horizontally.  @param img: Image to be flipped. @type img: np.ndarray @param params: Parameters for the transformation. @type params: Dict[str, Any]
method
apply_to_mask(self, img: np.ndarray, params) -> np.ndarray: np.ndarray
Flips segmentation masks horizontally.  @param img: Segmentation mask to be flipped. @param params: Parameters for the transformation.
method
apply_to_bboxes(self, bboxes: np.ndarray, params) -> np.ndarray: np.ndarray
Flips bounding boxes horizontally.  @param bboxes: Bounding boxes to be flipped. @type bboxes: np.ndarray @param params: Parameters for the transformation. @type params: Dict[str, Any]
method
apply_to_keypoints(self, keypoints: np.ndarray, orig_width: int, params) -> np.ndarray: np.ndarray
Flips keypoints horizontally and then swaps symmetric ones.  @param keypoints: Keypoints to be flipped. @type keypoints: np.ndarray @param orig_width: Width of the original image. @type orig_width: int @param params: Parameters for the transformation. @type params: Dict[str, Any]
class

luxonis_ml.data.augmentations.custom.TransposeSymmetricKeypoints(albumentations.DualTransform)

method
__init__(self, keypoint_pairs: list [ tuple [ int , int ] ], p: float = 0.5)
Augmentation to transpose an image along with bboxes, segmentation masks and symmetric keypoints.  Equivalent to 90 degree rotation followed by horizontal flip.  @param keypoint_pairs: List of tuples with indices to swap after     transposing. @param p: Probability of applying the augmentation.
variable
variable
property
method
get_params_dependent_on_data(self, params: dict [ str , Any ], data: dict [ str , Any ]) -> dict[str, Any]: dict[str, Any]
Get parameters dependent on the targets.  @param params: Dictionary containing parameters. @type params: dict[str, Any] @param data: Dictionary containing data. @type data: dict[str, Any]
method
apply(self, img: np.ndarray, params) -> np.ndarray: np.ndarray
Flips the image horizontally.  @param img: Image to be flipped. @type img: np.ndarray @param params: Parameters for the transformation. @type params: Dict[str, Any]
method
apply_to_mask(self, mask: np.ndarray, params) -> np.ndarray: np.ndarray
Flips segmentation masks horizontally.  @param img: Segmentation mask to be flipped. @param params: Parameters for the transformation.
method
apply_to_bboxes(self, bboxes: np.ndarray, params) -> np.ndarray: np.ndarray
Flips bounding boxes horizontally.  @param bboxes: Bounding boxes to be flipped. @type bboxes: np.ndarray @param params: Parameters for the transformation. @type params: Dict[str, Any]
method
apply_to_keypoints(self, keypoints: np.ndarray, params) -> np.ndarray: np.ndarray
Flips keypoints horizontally and then swaps symmetric ones.  @param keypoints: Keypoints to be flipped. @type keypoints: np.ndarray @param orig_width: Original width of the image. @type orig_width: int @param params: Parameters for the transformation. @type params: Dict[str, Any]
class

luxonis_ml.data.augmentations.custom.VerticalSymetricKeypointsFlip(albumentations.DualTransform)

method
__init__(self, keypoint_pairs: list [ tuple [ int , int ] ], p: float = 0.5)
Augmentation to vertically flip an image along with bboxes, segmentation masks and symmetric keypoints.  @param keypoint_pairs: List of tuples with indices to swap after     vertical flip. @type keypoint_pairs: list[tuple[int, int]] @param p: Probability of applying the augmentation. @type p: float
variable
variable
property
method
get_params_dependent_on_data(self, params: dict [ str , Any ], data: dict [ str , Any ]) -> dict[str, Any]: dict[str, Any]
Get parameters dependent on the targets.  @param params: Dictionary containing parameters. @type params: dict[str, Any] @param data: Dictionary containing data. @type data: dict[str, Any]
method
apply(self, img: np.ndarray, params) -> np.ndarray: np.ndarray
Flips the image vertically.  @param img: Image to be flipped. @type img: np.ndarray @param params: Parameters for the transformation. @type params: Dict[str, Any]
method
apply_to_mask(self, img: np.ndarray, params) -> np.ndarray: np.ndarray
Flips segmentation masks vertically.  @param img: Segmentation mask to be flipped. @type img: np.ndarray @param params: Parameters for the transformation. @type params: Dict[str, Any]
method
apply_to_bboxes(self, bboxes: np.ndarray, params) -> np.ndarray: np.ndarray
Flips bounding boxes vertically.  @param bboxes: Bounding boxes to be flipped. @type bboxes: np.ndarray @param params: Parameters for the transformation. @type params: Dict[str, Any]
method
apply_to_keypoints(self, keypoints: np.ndarray, orig_height: int, params) -> np.ndarray: np.ndarray
Flips keypoints vertically and then swaps symmetric ones.  @param keypoints: Keypoints to be flipped. @type keypoints: np.ndarray @param orig_height: Original height in the image. @type orig_height: int @param params: Parameters for the transformation. @type params: Dict[str, Any]
class

luxonis_ml.data.augmentations.AlbumentationsEngine(luxonis_ml.data.augmentations.AugmentationEngine)

method
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
property
method
method
preprocess_batch(self, labels_batch: list [ LoaderMultiOutput ]) -> tuple[list[Data], dict[str, int]]: tuple[list[Data], dict[str, int]]
Preprocess a batch of labels.  @type labels_batch: List[Data] @param labels_batch: List of dictionaries mapping task names to     the annotations as C{np.ndarray} @rtype: Tuple[List[Data], Dict[str, int]] @return: Tuple containing the preprocessed data and a dictionary     mapping task names to the number of keypoints for that task.
method
postprocess(self, data: Data, n_keypoints: dict [ str , int ]) -> LoaderMultiOutput: LoaderMultiOutput
Postprocess the augmented data back to LDF format.  Discards labels associated with bboxes that are outside the image.  @type data: Data @param data: Dictionary mapping task names to the annotations as     C{np.ndarray} @type n_keypoints: Dict[str, int] @param n_keypoints: Dictionary mapping task names to the number     of keypoints for that task. @rtype: LoaderMultiOutput @return: Tuple containing the augmented image dict and the     labels.
static method
static method
class

luxonis_ml.data.augmentations.AugmentationEngine(abc.ABC)

method
__init__(self, height: int, width: int, targets: Mapping [ str , str ], n_classes: Mapping [ str , int ], source_names: list [ str ], config: Iterable [ Params ], keep_aspect_ratio: bool, is_validation_pipeline: bool, min_bbox_visibility: float = 0.0, seed: int | None = None, bbox_area_threshold: float = 0.0004)
Initialize augmentation pipeline from configuration.  @type height: int @param height: Target image height @type width: int @param width: Target image width  @type targets: Dict[str, str] @param targets: Dictionary mapping task names to task types.     Example::         {             "detection/boundingbox": "bbox",             "detection/segmentation": "mask",         }  @type n_classes: Dict[str, int] @param n_classes: Dictionary mapping task names to the number     of associated classes. Example::         {             "cars/boundingbox": 2,             "cars/segmentation": 2,             "motorbikes/boundingbox": 1,         }  @type config: List[Params] @param config: List of dictionaries with configuration for each     augmentation. It is up to the augmentation engine to parse     and interpret this configuration.  @type keep_aspect_ratio: bool @param keep_aspect_ratio: Whether to keep aspect ratio @type is_validation_pipeline: bool @param is_validation_pipeline: Whether this is a validation     pipeline (in which case some augmentations are skipped) @type min_bbox_visibility: float @param min_bbox_visibility: Minimum fraction of the original bounding box that must remain visible after augmentation. @type bbox_area_threshold: float @param bbox_area_threshold: Minimum area threshold for bounding boxes to be considered valid. In the range [0, 1].     Default is 0.0004, which corresponds to a small area threshold to remove invalid bboxes and respective keypoints. @type seed: Optional[int] @param seed: Random seed for reproducibility. If None, a random seed will be used.     If provided, it will be used to initialize the random number generator.
method
apply(self, data: list [ LoaderMultiOutput ]) -> LoaderMultiOutput: LoaderMultiOutput
Apply the augmentation pipeline to the data.  @type data: List[LoaderMultiOutput] @param data: List of data to augment. The length of the list     must be equal to the batch size. @rtype: LoaderMultiOutput @return: Augmented data
property
batch_size
Getter for the batch size.  The batch size is the number of images necessary for the augmentation pipeline to work in case of batch-based augmentations.  For example, if the augmentation pipeline contains the MixUp augmentation, the batch size should be 2.  If the pipeline requires MixUp and also Mosaic4 augmentations, the batch size should be 8 (2 * 4).
class

luxonis_ml.data.augmentations.BatchCompose(albumentations.Compose)

variable
method
__init__(self, transforms: TransformsSeqType, kwargs)
Compose transforms and handle all transformations regarding bounding boxes.  @param transforms: List of transformations to compose @type transforms: TransformsSeqType @param kwargs: Additional arguments to pass to A.Compose
variable
method
static method
package

luxonis_ml.data.datasets

module
module
module
module
module
module
module
class
Annotation
Base class for an annotation.
class
ArrayAnnotation
A custom unspecified annotation that is an arbitrary numpy array.  All instances of this annotation must have the same shape.
class
BBoxAnnotation
Bounding box annotation.  Values are normalized based on the image size.
class
class
class
class
KeypointAnnotation
Keypoint annotation.  Values are normalized to [0, 1] based on the image size.
function
constant
class
BaseDataset
Base abstract dataset class for managing datasets in the Luxonis MLOps ecosystem.
type alias
class
class
UpdateMode
Update mode for the dataset.
class
class
LuxonisComponent
Abstraction for a piece of media within a source. Most commonly,  this abstracts an image sensor.
class
LuxonisSource
Abstracts the structure of a dataset and which components/media are included.  For example, with an OAK-D, you can have a source with 4 image components: rgb (color), left (mono), right (mono), and depth.
module

luxonis_ml.data.datasets.annotation

type alias
type alias
class
class
SegmentationAnnotation
Run-length encoded segmentation mask.
class
function
check_valid_identifier(name: str, label: str)
Check if a name is a valid Python identifier after converting dashes to underscores.  Albumentations requires that the names of the targets passed as `additional_targets` are valid Python identifiers.
class

luxonis_ml.data.datasets.annotation.ClassificationAnnotation(luxonis_ml.data.datasets.Annotation)

class

luxonis_ml.data.datasets.annotation.SegmentationAnnotation(luxonis_ml.data.datasets.Annotation)

variable
height
The height of the segmentation mask.
variable
width
The width of the segmentation mask.
variable
counts
The run-length encoded mask. This can be a list of integers or a byte string.
method
static method
method
CLASS_METHOD
CLASS_METHOD
CLASS_METHOD
class

luxonis_ml.data.datasets.annotation.InstanceSegmentationAnnotation(luxonis_ml.data.datasets.annotation.SegmentationAnnotation)

module

luxonis_ml.data.datasets.metadata

class

luxonis_ml.data.datasets.metadata.Skeletons(typing_extensions.TypedDict)

class

luxonis_ml.data.datasets.Annotation(abc.ABC, luxonis_ml.utils.BaseModelExtraForbid)

class

luxonis_ml.data.datasets.ArrayAnnotation(luxonis_ml.data.datasets.Annotation)

class

luxonis_ml.data.datasets.BBoxAnnotation(luxonis_ml.data.datasets.Annotation)

variable
x
The top-left x coordinate of the bounding box. Normalized to [0, 1].
variable
y
The top-left y coordinate of the bounding box. Normalized to [0, 1].
variable
w
The width of the bounding box. Normalized to [0, 1].
variable
h
The height of the bounding box. Normalized to [0, 1].
method
static method
CLASS_METHOD
class

luxonis_ml.data.datasets.Category(str)

class

luxonis_ml.data.datasets.DatasetRecord(luxonis_ml.utils.BaseModelExtraForbid)

variable
variable
variable
property
property
method
CLASS_METHOD
CLASS_METHOD
method
to_parquet_rows(self) -> Iterable[ParquetRecord]: Iterable[ParquetRecord]
Converts an annotation to a dictionary for writing to a parquet file.  @rtype: L{ParquetDict} @return: A dictionary of annotation data.
class

luxonis_ml.data.datasets.KeypointAnnotation(luxonis_ml.data.datasets.Annotation)

variable
keypoints
List of keypoints. Each keypoint is a tuple of (x, y, visibility). x and y are normalized to [0, 1]. visibility is one of 0, 1, or 2 where:  0: Not visible / not labeled  1: Occluded  2: Visible
method
static method
CLASS_METHOD
class

luxonis_ml.data.datasets.BaseDataset(abc.ABC)

property
identifier
The unique identifier for the dataset.
property
version
The version of the underlying LDF.
method
set_tasks(self, tasks: dict [ str , list [ str ] ])
Sets the tasks for the dataset.  @type tasks: Dict[str, List[str]] @param tasks: A dictionary mapping task names to task types.
method
get_tasks(self) -> dict[str, str]: dict[str, str]
Returns a dictionary mapping task names to task types.  @rtype: Dict[str, str] @return: A dictionary mapping task names to task types.
method
set_classes(self, classes: list [ str ] | dict [ str , int ], task: str | None = None)
Sets the classes for the dataset. This can be across all CV tasks or certain tasks.  @type classes: Union[List[str], Dict[str, int]] @param classes: Either a list of class names or a dictionary     mapping class names to class IDs. If list is provided, the     class IDs will be assigned I{alphabetically} starting from     C{0}. If the class names contain the class C{"background"},     it will be assigned the class ID C{0}. @type task: Optional[str] @param task: Optionally specify the task where these classes     apply.
method
get_source_names(self) -> list[str]: list[str]
Get the source of the input data for the dataset.  @rtype: List[str] @return: A list of source names, such as "image_left",     "image_right", "image_middle", etc. This is used to identify     the input data
method
update_source(self, source: LuxonisSource)
Updates underlying source of the dataset with a new LuxonisSource.  @type source: L{LuxonisSource} @param source: The new C{LuxonisSource} to replace the old one.
method
get_classes(self) -> dict[str, list[str]]: dict[str, list[str]]
Get classes according to computer vision tasks.  @rtype: Dict[str, List[str]] @return: A dictionary mapping tasks to the classes used in each     task.
method
set_skeletons(self, labels: list [ str ] | None = None, edges: list [ tuple [ int , int ] ] | None = None, task: str | None = None)
Sets the semantic structure of keypoint skeletons for the classes that use keypoints.  Example::      dataset.set_skeletons(         labels=["right hand", "right shoulder", ...],         edges=[[0, 1], [4, 5], ...]     )  @type labels: Optional[List[str]] @param labels: List of keypoint names. @type edges: Optional[List[Tuple[int, int]]] @param edges: List of edges between keypoints. @type task: Optional[str] @param task: Optionally specify the task where these skeletons apply.     If not specified, the skeletons are set for all tasks that use keypoints.
method
get_skeletons(self) -> dict[str, tuple[list[str], list[tuple[int, int]]]]: dict[str, tuple[list[str], list[tuple[int, int]]]]
Returns the dictionary defining the semantic skeleton for each class using keypoints.  @rtype: Dict[str, Tuple[List[str], List[Tuple[int, int]]]] @return: For each task, a tuple containing a list of keypoint     names and a list of edges between the keypoints.
method
add(self, generator: DatasetIterator, batch_size: int = 1000000)
Write annotations to parquet files.  @type generator: L{DatasetIterator} @param generator: A Python iterator that yields either instances     of C{DatasetRecord} or a dictionary that can be converted to     C{DatasetRecord}. @type batch_size: int @param batch_size: The number of annotations generated before     processing. This can be set to a lower value to reduce     memory usage.
method
make_splits(self, splits: dict [ str , Sequence [ PathType ] ] | dict [ str , float ] | tuple [ float , float , float ] | None = None, ratios: dict [ str , float ] | tuple [ float , float , float ] | None = None, definitions: dict [ str , list [ PathType ] ] | None = None, replace_old_splits: bool = False)
Generates splits for the dataset.  @type splits: Optional[Union[Dict[str, Sequence[PathType]], Dict[str, float], Tuple[float, float, float]]] @param splits: A dictionary of splits or a tuple of ratios for train, val, and test splits. Can be one of:     - A dictionary of splits with keys as split names and values as lists of filepaths     - A dictionary of splits with keys as split names and values as ratios     - A 3-tuple of ratios for train, val, and test splits @type ratios: Optional[Union[Dict[str, float], Tuple[float, float, float]]] @param ratios: Deprecated! A dictionary of splits with keys as split names and values as ratios. @type definitions: Optional[Dict[str, List[PathType]]] @param definitions: Deprecated! A dictionary of splits with keys as split names and values as lists of filepaths. @type replace_old_splits: bool @param replace_old_splits: Whether to remove old splits and generate new ones. If set to False, only new files will be added to the splits. Default is False.
method
delete_dataset(self)
Deletes all local files belonging to the dataset.
static method
BaseDataset.exists(dataset_name: str) -> bool: bool
Checks whether a dataset exists.  @warning: For offline mode only. @type dataset_name: str @param dataset_name: Name of the dataset @rtype: bool @return: Whether the dataset exists
method
get_task_names(self) -> list[str]: list[str]
Get the task names for the dataset.  Like `get_tasks`, but returns only the task names instead of the entire names.  @rtype: List[str] @return: List of task names.
method
class

luxonis_ml.data.datasets.LuxonisDataset(luxonis_ml.data.datasets.BaseDataset)

method
__init__(self, dataset_name: str, team_id: str | None = None, bucket_type: BucketType | Literal [ ' internal ' , ' external ' ] = BucketType.INTERNAL, bucket_storage: BucketStorage | Literal [ ' local ' , ' gcs ' , ' s3 ' , ' azure ' ] = BucketStorage.LOCAL, delete_local: bool = False, delete_remote: bool = False)
Luxonis Dataset Format (LDF) is used to define datasets in the Luxonis MLOps ecosystem.  @type dataset_name: str @param dataset_name: Name of the dataset @type team_id: Optional[str] @param team_id: Optional unique team identifier for the cloud @type bucket_type: BucketType @param bucket_type: Whether to use external cloud buckets @type bucket_storage: BucketStorage @param bucket_storage: Underlying bucket storage. Can be one of     C{local}, C{S3}, or C{GCS}. @type delete_local: bool @param delete_local: Whether to delete a dataset with the same     name if it exists @type delete_remote: bool @param delete_remote: Whether to delete the dataset from the     cloud as well
variable
variable
variable
variable
variable
variable
variable
variable
property
metadata
Returns a copy of the dataset metadata.  The metadata is a pydantic model with the following fields:  source: LuxonisSource  ldf_version: str  classes: Dict[task_name, Dict[class_name, class_id]]  tasks: Dict[task_name, List[task_type]]  skeletons: Dict[task_name, Skeletons]  Skeletons is a dictionary with keys 'labels' and 'edges'  labels: List[str]  edges: List[Tuple[int, int]]  categorical_encodings: Dict[task_name, Dict[metadata_name, Dict[metadata_value, int]]]  Encodings for string metadata values  Example:        {           "vehicle": {               "color": {"red": 0, "green": 1, "blue": 2},               "brand": {"audi": 0, "bmw": 1, "mercedes": 2},           }       }
property
property
property
method
__len__(self) -> int: int
Returns the number of instances in the dataset.
variable
variable
variable
variable
variable
variable
method
clone(self, new_dataset_name: str, push_to_cloud: bool = True, splits_to_clone: list [ str ] | None = None, team_id: str | None = None) -> LuxonisDataset: LuxonisDataset
Create a new LuxonisDataset that is a local copy of the current dataset. Cloned dataset will overwrite the existing dataset with the same name.  @type new_dataset_name: str @param new_dataset_name: Name of the newly created dataset. @type push_to_cloud: bool @param push_to_cloud: Whether to push the new dataset to the     cloud. Only if the current dataset is remote. @param splits_to_clone: list[str] | None @type splits_to_clone: Optional list of split names to clone. If     None, all data will be cloned. @type team_id: str | None @param team_id: Optional team identifier.
method
merge_with(self, other: LuxonisDataset, inplace: bool = True, new_dataset_name: str | None = None, splits_to_merge: list [ str ] | None = None, team_id: str | None = None) -> LuxonisDataset: LuxonisDataset
Merge all data from `other` LuxonisDataset into the current dataset (in-place or in a new dataset).  @type other: LuxonisDataset @param other: The dataset to merge into the current dataset. @type inplace: bool @param inplace: Whether to merge into the current dataset (True)     or create a new dataset (False). @type new_dataset_name: str @param new_dataset_name: The name of the new dataset to create     if inplace is False. @type splits_to_merge: list[str] | None @param splits_to_merge: Optional list of split names to merge. @type team_id: str | None @param team_id: Optional team identifier.
property
method
method
method
method
method
get_n_classes(self) -> dict[str, int]: dict[str, int]
Returns a mapping of task names to number of classes.  @rtype: Dict[str, int] @return: A mapping from task names to number of classes.
method
method
method
method
method
method
method
pull_from_cloud(self, update_mode: UpdateMode = UpdateMode.MISSING)
Synchronizes the dataset from a remote cloud bucket to the local directory.  This method performs the download only if some local dataset media files are missing, or always downloads depending on the provided update_mode.  @type update_mode: UpdateMode @param update_mode: Specifies the update behavior.     - UpdateMode.MISSING: Downloads only the missing media files for the dataset.     - UpdateMode.ALL: Always downloads and overwrites all media files in the local dataset.
method
push_to_cloud(self, bucket_storage: BucketStorage, update_mode: UpdateMode = UpdateMode.MISSING)
Pushes the local dataset to a remote cloud bucket.  This method performs the pushing only for missing cloud media files or always pushes depending on the provided update_mode.  @type update_mode: UpdateMode @param update_mode: Specifies the update behavior. Annotations and metadata are always pushed.     - UpdateMode.MISSING: Pushes only the missing media files for the dataset.     - UpdateMode.ALL:  Always pushes and overwrites all media files in the cloud dataset.
method
delete_dataset(self, delete_remote: bool = False, delete_local: bool = False)
Deletes the dataset from local storage and optionally from the cloud.  @type delete_remote: bool @param delete_remote: Whether to delete the dataset from the     cloud. @type delete_local: bool @param delete_local: Whether to delete the dataset from local     storage.
method
method
method
static method
LuxonisDataset.exists(dataset_name: str, team_id: str | None = None, bucket_storage: BucketStorage = BucketStorage.LOCAL, bucket: str | None = None) -> bool: bool
Checks if a dataset exists.  @type dataset_name: str @param dataset_name: Name of the dataset to check @type team_id: Optional[str] @param team_id: Optional team identifier @type bucket_storage: BucketStorage @param bucket_storage: Underlying bucket storage from C{local},     C{S3}, or C{GCS}. Default is C{local}. @type bucket: Optional[str] @param bucket: Name of the bucket. Default is C{None}. @rtype: bool @return: Whether the dataset exists.
static method
LuxonisDataset.list_datasets(team_id: str | None = None, bucket_storage: BucketStorage = BucketStorage.LOCAL, bucket: str | None = None) -> list[str]: list[str]
Returns a list of all datasets.  @type team_id: Optional[str] @param team_id: Optional team identifier @type bucket_storage: BucketStorage @param bucket_storage: Underlying bucket storage (local, S3, or     GCS). Default is local. @type bucket: Optional[str] @param bucket: Name of the bucket. Default is None. @rtype: List[str] @return: List of all dataset names.
method
export(self, output_path: PathType, dataset_type: DatasetType = DatasetType.NATIVE, max_partition_size_gb: float | None = None, zip_output: bool = False) -> Path|list[Path]: Path|list[Path]
Exports the dataset into one of the supported formats.  @type output_path: PathType @param output_path: Path to the directory where the dataset will     be exported. @type dataset_type: DatasetType @param dataset_type: To what format to export the dataset.     Currently only DatasetType.NATIVE is supported. @type max_partition_size_gb: Optional[float] @param max_partition_size_gb: Maximum size of each partition in     GB. If the dataset exceeds this size, it will be split into     multiple partitions named     {dataset_name}_part{partition_number}. Default is None,     meaning the dataset will be exported as a single partition     named {dataset_name}. @type zip_output: bool @param zip_output: Whether to zip the exported dataset (or each     partition) after export. Default is False. @rtype: Union[Path, List[Path]] @return: Path(s) to the ZIP file(s) containing the exported     dataset.
method
get_statistics(self, sample_size: int | None = None, view: str | None = None) -> dict[str, Any]: dict[str, Any]
Returns comprehensive dataset statistics as a structured dictionary for the given view or the entire dataset.  The returned dictionary contains:      - "duplicates": Analysis of duplicated content         - "duplicate_uuids": List of {"uuid": str, "files": List[str]} for images with same UUID         - "duplicate_annotations": List of repeated annotations with file_name, task_name, task_type,             annotation content, and count      - "class_distributions": Nested dictionary of class frequencies organized by task_name and task_type     (excludes classification tasks)      - "missing_annotations": List of file paths that exist in the dataset but lack annotations      - "heatmaps": Spatial distribution of annotations as 15x15 grid matrices organized by task_name and task_type  @type sample_size: Optional[int] @param sample_size: Number of samples to use for heatmap generation @type view: Optional[str] @param view: Name of the view to analyze. If None, the entire dataset is analyzed. @rtype: Dict[str, Any] @return: Dataset statistics dictionary as described above
method
remove_duplicates(self)
Removes duplicate files and annotations from the dataset.
method
set_class_order_per_task(self, class_order_per_task: dict [ str , list [ str ] ])
Sets the class order for provided tasks. This method checks if the provided class order matches the dataset's classes and updates the dataset accordingly.  @type class_order_per_task: dict[str, list[str]] @param class_order_per_task: A dictionary mapping task names to     a list of class names. The class names must match the     dataset's classes for the respective tasks. @raises ValueError: If the task name is not found in the dataset     tasks or if the provided class names do not match the     dataset's classes.
class

luxonis_ml.data.datasets.UpdateMode(enum.Enum)

constant
constant
class

luxonis_ml.data.datasets.LuxonisComponent(luxonis_ml.utils.BaseModelExtraForbid)

variable
name
A recognizable name for the component.
variable
media_type
Enum for the type of media for the component.
variable
image_type
Enum for the image type. Only used if media_type==MediaType.IMAGE.
class

luxonis_ml.data.datasets.LuxonisSource(luxonis_ml.utils.BaseModelExtraForbid)

variable
name
A recognizable name for the source. Defaults to "default".
variable
components
If not using the default configuration, a list of LuxonisComponent to group together in the source.
variable
main_component
The name of the component that should be primarily visualized.
method
merge_with(self, other: LuxonisSource) -> LuxonisSource: LuxonisSource
Merge two sources together.  @type other: LuxonisSource @param other: The other source to merge with. @rtype: LuxonisSource @return: A new source with the components of both sources.
CLASS_METHOD
package

luxonis_ml.data.loaders

module
module
constant
class
BaseLoader
Base abstract loader class.  Enforces the LuxonisLoaderOutput output label structure.
class
class

luxonis_ml.data.loaders.BaseLoader(abc.ABC)

method
__len__(self) -> int: int
Returns the length of the dataset.  @rtype: int @return: Length of the dataset.
method
__getitem__(self, idx: int) -> LoaderOutput: LoaderOutput
Loads sample from dataset.  @type idx: int @param idx: Index of the sample to load. @rtype: L{LuxonisLoaderOutput} @return: Sample's data in C{LuxonisLoaderOutput} format.
method
__iter__(self) -> Iterator[LoaderOutput]: Iterator[LoaderOutput]
Iterates over the dataset.  @rtype: Iterator[L{LuxonisLoaderOutput}] @return: Iterator over the dataset.
class

luxonis_ml.data.loaders.LuxonisLoader(luxonis_ml.data.loaders.BaseLoader)

method
__init__(self, dataset: LuxonisDataset, view: str | list [ str ] = 'train', augmentation_engine: Literal [ ' albumentations ' ] | str = 'albumentations', augmentation_config: list [ Params ] | PathType | None = None, height: int | None = None, width: int | None = None, keep_aspect_ratio: bool = True, exclude_empty_annotations: bool = False, color_space: dict [ str , Literal [ ' RGB ' , ' BGR ' , ' GRAY ' ] ] | Literal [ ' RGB ' , ' BGR ' , ' GRAY ' ] | None = None, seed: int | None = None, min_bbox_visibility: float = 0.0, bbox_area_threshold: float = 0.0004, keep_categorical_as_strings: bool = False, update_mode: UpdateMode | Literal [ ' all ' , ' missing ' ] = UpdateMode.ALL, filter_task_names: list [ str ] | None = None)
A loader class used for loading data from L{LuxonisDataset}.  @type dataset: LuxonisDataset @param dataset: Instance of C{LuxonisDataset} to use. @type view: Union[str, List[str]] @param view: What splits to use. Can be either a single split or     a list of splits. Defaults to C{"train"}. @type augmentation_engine: Union[Literal["albumentations"], str] @param augmentation_engine: The augmentation engine to use.     Defaults to C{"albumentations"}. @type augmentation_config: Optional[Union[List[Params],     PathType]] @param augmentation_config: The configuration for the     augmentations. This can be either a list of C{Dict[str, JsonValue]} or     a path to a configuration file.     The config member is a dictionary with two keys: C{name} and     C{params}. C{name} is the name of the augmentation to     instantiate and C{params} is an optional dictionary     of parameters to pass to the augmentation.      Example::          [             {"name": "HorizontalFlip", "params": {"p": 0.5}},             {"name": "RandomBrightnessContrast", "params": {"p": 0.1}},             {"name": "Defocus"}         ]  @type height: Optional[int] @param height: The height of the output images. Defaults to     C{None}. @type width: Optional[int] @param width: The width of the output images. Defaults to     C{None}. @type keep_aspect_ratio: bool @param keep_aspect_ratio: Whether to keep the aspect ratio of the     images. Defaults to C{True}. @type color_space: Optional[Union[dict[str, Literal["RGB", "BGR", "GRAY"]], Literal["RGB", "BGR", "GRAY"]]] @param color_space: The color space to use for the images.     If a string is provided, it will be used for all sources. If not provided, the default is C{"RGB"} for all sources. @type seed: Optional[int] @param seed: The random seed to use for the augmentations. @type min_bbox_visibility: float @param min_bbox_visibility: Minimum fraction of the original bounding box that must remain visible after augmentation. @type bbox_area_threshold: float @param bbox_area_threshold: Minimum area threshold for bounding boxes to be considered valid. In the range [0, 1].     Default is 0.0004, which corresponds to a small area threshold to remove invalid bboxes and respective keypoints. @type exclude_empty_annotations: bool @param exclude_empty_annotations: Whether to exclude     empty annotations from the final label dictionary.     Defaults to C{False} (i.e. include empty annotations).  @type keep_categorical_as_strings: bool @param keep_categorical_as_strings: Whether to keep categorical     metadata labels as strings.     Defaults to C{False} (i.e. convert categorical labels to integers).  @type update_mode: UpdateMode @param update_mode: Enum that determines the sync mode for media files of the remote dataset (annotations and metadata are always overwritten):     - UpdateMode.MISSING: Downloads only the missing media files for the dataset.     - UpdateMode.ALL: Always downloads and overwrites all media files in the local dataset.  @type filter_task_names: Optional[List[str]] @param filter_task_names: List of task names to filter the dataset by.     If C{None}, all task names are included. Defaults to C{None}.     This is useful for filtering out tasks that are not needed for a specific use case.
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
method
__len__(self) -> int: int
Returns length of the dataset.  @rtype: int @return: Length of the loader.
method
__getitem__(self, idx: int) -> LoaderOutput: LoaderOutput
Function to load a sample consisting of an image and its annotations.  @type idx: int @param idx: The integer index of the sample to retrieve. @rtype: L{LuxonisLoaderOutput} @return: The loader ouput consisting of the image and a     dictionary defining its annotations.
variable
package

luxonis_ml.data.parsers

module
module
module
module
module
module
module
module
module
module
module
module
module
class
class
ClassificationDirectoryParser
Parses directory with ClassificationDirectory annotations to LDF.  Expected format:      dataset_dir/     ├── train/     │   ├── class1/     │   │   ├── img1.jpg     │   │   ├── img2.jpg     │   │   └── ...     │   ├── class2/     │   └── ...     ├── valid/     └── test/  This is one of the formats that can be generated by Roboflow.
class
COCOParser
Parses directory with COCO annotations to LDF.  Expected formats:      dataset_dir/     ├── train/     │   ├── data/     │   │   ├── img1.jpg     │   │   ├── img2.jpg     │   │   └── ...     │   └── labels.json     ├── validation/     │   ├── data/     │   └── labels.json     └── test/         ├── data/         └── labels.json      This is default format returned when using FiftyOne package.  or:      dataset_dir/         ├── train/         │   ├── img1.jpg         │   ├── img2.jpg         │   └── ...         │   └── _annotations.coco.json         ├── valid/         └── test/      This is one of the formats that can be generated by     U{Roboflow <https://roboflow.com/>}.
class
CreateMLParser
Parses directory with CreateML annotations to LDF.  Expected format:      dataset_dir/     ├── train/     │   ├── img1.jpg     │   ├── img2.jpg     │   └── ...     │   └── _annotations.createml.json     ├── valid/     └── test/  This is one of the formats that can be generated by Roboflow.
class
DarknetParser
Parses directory with DarkNet annotations to LDF.  Expected format:      dataset_dir/     ├── train/     │   ├── img1.jpg     │   ├── img1.txt     │   ├── ...     │   └── _darknet.labels     ├── valid/     └── test/  This is one of the formats that can be generated by Roboflow.
class
class
SegmentationMaskDirectoryParser
Parses directory with SegmentationMask annotations to LDF.  Expected format:      dataset_dir/     ├── train/     │   ├── img1.jpg     │   ├── img1_mask.png     │   ├── ...     │   └── _classes.csv     ├── valid/     └── test/  _classes.csv contains mappings between pixel value and class name.  This is one of the formats that can be generated by Roboflow.
class
SOLOParser
Parses directory with SOLO annotations to LDF.  Expected format:      dataset_dir/     ├── train/     │   ├── metadata.json     │   ├── sensor_definitions.json     │   ├── annotation_definitions.json     │   ├── metric_definitions.json     │   └── sequence.<SequenceNUM>/     │       ├── step<StepNUM>.camera.jpg     │       ├── step<StepNUM>.frame_data.json     │       └── (OPTIONAL: step<StepNUM>.camera.semantic segmentation.jpg)     ├── valid/     └── test/  This is the default format returned by Unity simulation engine.
class
TensorflowCSVParser
Parses directory with TensorflowCSV annotations to LDF.  Expected format:      dataset_dir/     ├── train/     │   ├── img1.jpg     │   ├── img2.jpg     │   ├── ...     │   └── _annotations.csv     ├── valid/     └── test/  This is one of the formats that can be generated by Roboflow.
class
VOCParser
Parses directory with VOC annotations to LDF.  Expected format:      dataset_dir/     ├── train/     │   ├── img1.jpg     │   ├── img1.xml     │   └── ...     ├── valid/     └── test/  This is one of the formats that can be generated by Roboflow.
class
YoloV4Parser
Parses directory with YoloV4 annotations to LDF.  Expected format:      dataset_dir/     ├── train/     │   ├── img1.jpg     │   ├── img2.jpg     │   ├── ...     │   ├── _annotations.txt     │   └── _classes.txt     ├── valid/     └── test/  This is one of the formats that can be generated by Roboflow.
class
YoloV6Parser
Parses annotations from YoloV6 annotations to LDF.  Expected format:      dataset_dir/     ├── images/     │   ├── train/     │   │   ├── img1.jpg     │   │   ├── img2.jpg     │   │   └── ...     │   ├── valid/     │   └── test/     ├── labels/     │   ├── train/     │   │   ├── img1.txt     │   │   ├── img2.txt     │   │   └── ...     │   ├── valid/     │   └── test/     └── data.yaml  data.yaml contains names of all present classes.  This is one of the formats that can be generated by Roboflow.
module

luxonis_ml.data.parsers.base_parser

type alias
module

luxonis_ml.data.parsers.coco_parser

class
function
clean_annotations(annotation_path: Path) -> Path: Path
Cleans annotations by removing images that are known to cause issues.  @type annotation_path: Path @param annotation_path: Path to the annotation JSON file. @rtype: Path @return: Path to the cleaned annotation JSON file     ("labels_fixed.json").
class

luxonis_ml.data.parsers.coco_parser.Format(str, enum.Enum)

module

luxonis_ml.data.parsers.luxonis_parser

class
type variable
class

luxonis_ml.data.parsers.luxonis_parser.ParserType(enum.Enum)

constant
constant
module

luxonis_ml.data.parsers.native_parser

class

luxonis_ml.data.parsers.native_parser.NativeParser(luxonis_ml.data.parsers.base_parser.BaseParser)

constant
SPLIT_NAMES: tuple[str, ...]
Parses directory with native LDF annotations.  Expected format::      dataset_dir/     ├── train/     │   └── annotations.json     ├── valid/     └── test/  The annotations are stored in a single JSON file as a list of dictionaries in the same format as the output of the generator function used in L{BaseDataset.add} method.
static method
method
method
from_split(self, annotation_path: Path) -> ParserOutput: ParserOutput
Parses annotations from LDF Format.  @type annotation_path: C{Path} @param annotation_dir: Path to the JSON file with annotations. @rtype: L{ParserOutput} @return: Annotation generator, list of classes names, skeleton     dictionary for keypoints and list of added images.
class

luxonis_ml.data.parsers.BaseParser(abc.ABC)

constant
method
__init__(self, dataset: BaseDataset, dataset_type: DatasetType, task_name: str | dict [ str , str ] | None)
@type dataset: BaseDataset @param dataset: Dataset to add the parsed data to. @type dataset_type: DatasetType @param dataset_type: Type of the dataset. @type task_name: Optional[Union[str, Dict[str, str]]] @param task_name: Optional task name(s) for the dataset.     Can be either a single string, in which case all the records     added to the dataset will use this value as `task_name`, or     a dictionary with class names as keys and task names as values.     In the latter case, the task name for a record with a given     class name will be taken from the dictionary.
variable
variable
variable
static method
BaseParser.validate_split(split_path: Path) -> dict[str, Any]|None: dict[str, Any]|None
Validates if a split subdirectory is in an expected format. If so, returns kwargs to pass to L{from_split} method.  @type split_path: Path @param split_path: Path to split directory. @rtype: Optional[Dict[str, Any]] @return: Dictionary with kwargs to pass to L{from_split} method     or C{None} if the split is not in the expected format.
CLASS_METHOD
validate
Validates if the dataset is in an expected format.  @type dataset_dir: Path @param dataset_dir: Path to source dataset directory. @rtype: bool @return: If the dataset is in the expected format.
method
from_dir(self, dataset_dir: Path, kwargs) -> tuple[list[str], list[str], list[str]]: tuple[list[str], list[str], list[str]]
Parses all present data to L{LuxonisDataset} format.  @type dataset_dir: str @param dataset_dir: Path to source dataset directory. @type kwargs: Any @param kwargs: Additional arguments for a specific parser     implementation. @rtype: Tuple[List[str], List[str], List[str]] @return: Tuple with added images for C{train}, C{val} and     C{test} splits.
method
from_split(self, kwargs) -> ParserOutput: ParserOutput
Parses a data in a split subdirectory to L{LuxonisDataset} format.  @type kwargs: Dict[str, Any] @param kwargs: Additional kwargs for specific parser implementation.     Should work together with L{validate_split} method like:          >>> from_split(**validate_split(split_path))  @rtype: ParserOutput @return: C{LDF} generator, list of class names,     skeleton dictionary for keypoints and list of added images.
method
parse_split(self, split: str | None = None, random_split: bool = False, split_ratios: dict [ str , float ] | None = None, kwargs) -> BaseDataset: BaseDataset
Parses data in a split subdirectory to L{LuxonisDataset} format.  @type split: Optional[str] @param split: As what split the data will be added to LDF. If     set, C{split_ratios} and C{random_split} are ignored. @type random_split: bool @param random_split: If random splits should be made. If     C{True}, C{split_ratios} are used. @type split_ratios: Optional[Tuple[float, float, float]] @param split_ratios: Ratios for random splits. Only used if     C{random_split} is C{True}. Defaults to C{(0.8, 0.1, 0.1)}. @type kwargs: Dict[str, Any] @param kwargs: Additional C{kwargs} for specific parser     implementation. @rtype: LuxonisDataset @return: C{LDF} with all the images and annotations parsed.
method
parse_dir(self, dataset_dir: Path, kwargs) -> BaseDataset: BaseDataset
Parses entire dataset directory to L{LuxonisDataset} format.  @type dataset_dir: str @param dataset_dir: Path to source dataset directory. @type kwargs: Dict[str, Any] @param kwargs: Additional C{kwargs} for specific parser     implementation. @rtype: LuxonisDataset @return: C{LDF} with all the images and annotations parsed.
class

luxonis_ml.data.parsers.ClassificationDirectoryParser(luxonis_ml.data.parsers.BaseParser)

static method
method
method
from_split(self, class_dir: Path) -> ParserOutput: ParserOutput
Parses annotations from classification directory format to LDF. Annotations include classification.  @type class_dir: Path @param class_dir: Path to top level directory @rtype: L{ParserOutput} @return: Annotation generator, list of classes names, skeleton     dictionary for keypoints and list of added images.
class

luxonis_ml.data.parsers.COCOParser(luxonis_ml.data.parsers.BaseParser)

static method
CLASS_METHOD
method
method
from_split(self, image_dir: Path, annotation_path: Path) -> ParserOutput: ParserOutput
Parses annotations from COCO format to LDF. Annotations include classification, segmentation, object detection and keypoints if present.  @type image_dir: Path @param image_dir: Path to directory with images @type annotation_path: Path @param annotation_path: Path to annotation json file @rtype: L{ParserOutput} @return: Annotation generator, list of classes names, skeleton     dictionary for keypoints and list of added images.
class

luxonis_ml.data.parsers.CreateMLParser(luxonis_ml.data.parsers.BaseParser)

static method
method
method
from_split(self, image_dir: Path, annotation_path: Path) -> ParserOutput: ParserOutput
Parses annotations from CreateML format to LDF. Annotations include classification and object detection.  @type image_dir: Path @param image_dir: Path to directory with images @type annotation_path: Path @param annotation_path: Path to annotation json file @rtype: L{ParserOutput} @return: Annotation generator, list of classes names, skeleton     dictionary for keypoints and list of added images.
class

luxonis_ml.data.parsers.DarknetParser(luxonis_ml.data.parsers.BaseParser)

static method
method
method
from_split(self, image_dir: Path, classes_path: Path) -> ParserOutput: ParserOutput
Parses annotations from Darknet format to LDF. Annotations include classification and object detection.  @type image_dir: Path @param image_dir: Path to directory with images @type classes_path: Path @param classes_path: Path to file with class names @rtype: L{ParserOutput} @return: Annotation generator, list of classes names, skeleton     dictionary for keypoints and list of added images.
class

luxonis_ml.data.parsers.LuxonisParser(typing.Generic)

variable
method
__init__(self, dataset_dir: str, dataset_name: str | None = None, save_dir: Path | str | None = None, dataset_plugin: T = None, dataset_type: DatasetType | None = None, task_name: str | dict [ str , str ] | None = None, kwargs)
High-level abstraction over various parsers.  Automatically recognizes the dataset format and uses the appropriate parser.  @type dataset_dir: str @param dataset_dir: Identifier of the dataset directory.     Can be one of:         - Local path to the dataset directory.         - Remote URL supported by L{LuxonisFileSystem}.           - C{gcs://} for Google Cloud Storage           - C{s3://} for Amazon S3         - C{roboflow://} for Roboflow datasets.           - Expected format: C{roboflow://workspace/project/version/format}.     Can be a remote URL supported by L{LuxonisFileSystem}. @type dataset_name: Optional[str] @param dataset_name: Name of the dataset. If C{None}, the name     is derived from the name of the dataset directory. @type save_dir: Optional[Union[Path, str]] @param save_dir: If a remote URL is provided in C{dataset_dir},     the dataset will be downloaded to this directory. If     C{None}, the dataset will be downloaded to the current     working directory. @type dataset_plugin: Optional[str] @param dataset_plugin: Name of the dataset plugin to use. If     C{None}, C{LuxonisDataset} is used. @type dataset_type: Optional[DatasetType] @param dataset_type: If provided, the parser will use this     dataset type instead of trying to recognize it     automatically. @type task_name: Optional[Union[str, Dict[str, str]]] @param task_name: Optional task name(s) for the dataset.     Can be either a single string, in which case all the records     added to the dataset will use this value as `task_name`, or     a dictionary with class names as keys and task names as values.     In the latter case, the task name for a record with a given     class name will be taken from the dictionary. @type kwargs: Dict[str, Any] @param kwargs: Additional C{kwargs} to be passed to the     constructor of specific L{BaseDataset} implementation.
variable
variable
variable
variable
variable
variable
method
parse(self, kwargs) -> BaseDataset: BaseDataset
Parses the dataset and returns it in LuxonisDataset format.  If the dataset already exists, parsing will be skipped and the existing dataset will be returned instead.  @type kwargs: Dict[str, Any] @param kwargs: Additional C{kwargs} for specific parser     implementation. @rtype: LuxonisDataset @return: Parsed dataset in L{LuxonisDataset} format.
class

luxonis_ml.data.parsers.SegmentationMaskDirectoryParser(luxonis_ml.data.parsers.BaseParser)

static method
method
method
from_split(self, image_dir: Path, seg_dir: Path, classes_path: Path) -> ParserOutput: ParserOutput
Parses annotations with SegmentationMask format to LDF.  Annotations include classification and segmentation.  @type image_dir: Path @param image_dir: Path to directory with images @type seg_dir: Path @param seg_dir: Path to directory with segmentation mask @type classes_path: Path @param classes_path: Path to CSV file with class names @rtype: L{ParserOutput} @return: Annotation generator, list of classes names, skeleton     dictionary for keypoints and list of added images
class

luxonis_ml.data.parsers.SOLOParser(luxonis_ml.data.parsers.BaseParser)

static method
SOLOParser.validate_split(split_path: Path) -> dict[str, Any]|None: dict[str, Any]|None
Validates if a split subdirectory is in an expected format.  @type split_path: Path @param split_path: Path to split directory. @rtype: Optional[Dict[str, Any]] @return: Dictionary with kwargs to pass to L{from_split} method     or C{None} if the split is not in the expected format.
method
from_dir(self, dataset_dir: Path) -> tuple[list[Path], list[Path], list[Path]]: tuple[list[Path], list[Path], list[Path]]
Parses all present data to L{LuxonisDataset} format.  @type dataset_dir: str @param dataset_dir: Path to source dataset directory. @rtype: Tuple[List[Path], List[Path], List[Path]] @return: Tuple with added images for train, valid and test     splits.
method
from_split(self, split_path: Path) -> ParserOutput: ParserOutput
Parses data in a split subdirectory from SOLO format to L{LuxonisDataset} format.  @type split_path: Path @param split_path: Path to directory with sequences of images     and annotations. @rtype: L{ParserOutput} @return: C{LuxonisDataset} generator, list of class names,     skeleton dictionary for keypoints and list of added images.
class

luxonis_ml.data.parsers.TensorflowCSVParser(luxonis_ml.data.parsers.BaseParser)

static method
method
method
from_split(self, image_dir: Path, annotation_path: Path) -> ParserOutput: ParserOutput
Parses annotations from TensorflowCSV format to LDF. Annotations include classification and object detection.  @type image_dir: Path @param image_dir: Path to directory with images @type annotation_path: Path @param annotation_path: Path to annotation CSV file @rtype: L{ParserOutput} @return: Annotation generator, list of classes names, skeleton     dictionary for
class

luxonis_ml.data.parsers.VOCParser(luxonis_ml.data.parsers.BaseParser)

static method
method
method
from_split(self, image_dir: Path, annotation_dir: Path) -> ParserOutput: ParserOutput
Parses annotations from VOC format to LDF. Annotations include classification and object detection.  @type image_dir: Path @param image_dir: Path to directory with images @type annotation_dir: Path @param annotation_dir: Path to directory with C{.xml}     annotations @rtype: L{ParserOutput} @return: Annotation generator, list of classes names, skeleton     dictionary for keypoints and list of added images.
class

luxonis_ml.data.parsers.YoloV4Parser(luxonis_ml.data.parsers.BaseParser)

static method
method
method
from_split(self, image_dir: Path, annotation_path: Path, classes_path: Path) -> ParserOutput: ParserOutput
Parses annotations from YoloV4 format to LDF. Annotations include classification and object detection.  @type image_dir: Path @param image_dir: Path to directory with images @type annotation_path: Path @param annotation_path: Path to annotation file @type classes_path: Path @param classes_path: Path to file with class names @rtype: L{ParserOutput} @return: Annotation generator, list of classes names, skeleton     dictionary for keypoints and list of added images.
class

luxonis_ml.data.parsers.YoloV6Parser(luxonis_ml.data.parsers.BaseParser)

static method
CLASS_METHOD
method
method
from_split(self, image_dir: Path, annotation_dir: Path, classes_path: Path) -> ParserOutput: ParserOutput
Parses annotations from YoloV6 format to LDF. Annotations include classification and object detection.  @type image_dir: Path @param image_dir: Path to directory with images @type annotation_dir: Path @param annotation_dir: Path to directory with annotations @type classes_path: Path @param classes_path: Path to yaml file with classes names @rtype: L{ParserOutput} @return: Annotation generator, list of classes names, skeleton     dictionary for keypoints and list of added images.
package

luxonis_ml.data.utils

module
module
module
module
module
module
module
function
find_duplicates(df: pl.LazyFrame) -> dict[str, list[dict[str, Any]]]: dict[str, list[dict[str, Any]]]
Collects information about duplicate UUIDs and duplicate annotations in the dataset.  @type df: pl.LazyFrame @param df: Polars lazy frame containing dataset information. @rtype: Dict[str, List[Dict[str, Any]]] @return: A dictionary with two keys:     - "duplicate_uuids": list of dicts with "uuid" as key and "files" as value     - "duplicate_annotations": list of dicts with "file_name", "task_type",       "task_name", "annotation", and "count"
function
get_class_distributions(df: pl.LazyFrame) -> dict[str, dict[str, list[dict[str, Any]]]]: dict[str, dict[str, list[dict[str, Any]]]]
Gets class distribution info for non-classification tasks.  @type df: pl.LazyFrame @param df: Polars lazy frame containing dataset information. @rtype: Dict[str, Dict[str, List[Dict[str, Any]]]] @return: A dictionary with task names as keys, and dictionaries with     task types as keys and lists of dictionaries with class names     and counts as values.
function
get_duplicates_info(df: pl.LazyFrame) -> dict[str, Any]: dict[str, Any]
Collects and returns information about duplicate UUIDs and annotations.  @type df: pl.DataFrame @param df: Polars DataFrame containing dataset information. @rtype: Dict[str, Any] @return: A dictionary with two keys:     - "duplicate_uuids": list of dicts with "uuid" as key and "files" as value     - "duplicate_annotations": list of dicts with "file_name", "task_name",       "task_type", "annotation", and "count"
function
get_heatmaps(df: pl.LazyFrame, sample_size: int | None = None, downsample_factor: int = 5) -> dict[str, dict[str, list[list[int]]]]: dict[str, dict[str, list[list[int]]]]
Generates heatmaps for bounding boxes, keypoints, and segmentations.  @type df: pl.LazyFrame @param df: Polars lazy frame containing dataset information. @type sample_size: Optional[int] @param sample_size: Number of samples to take from the dataset.     Default is None. @type downsample_factor: int @param downsample_factor: Factor to downsample the segmentation     masks. @rtype: Dict[str, Dict[str, List[List[int]]]] @return: A dictionary with task names as keys, and dictionaries with     task types as keys and lists of lists of integers representing     the heatmaps as values
function
get_missing_annotations(df: pl.LazyFrame) -> list[str]: list[str]
Returns file paths that exist but have no annotations.  @type df: pl.LazyFrame @param df: Polars lazy frame containing dataset information. @rtype: List[str] @return: A list of file paths that exist but have no annotations.
function
function
merge_uuids(uuids: Iterable [ str ]) -> uuid.UUID: uuid.UUID
Merge multiple UUIDs into a single deterministic UUID, independent of order.  @param uuids: Iterable of UUID strings @return: Merged UUID
function
rgb_to_bool_masks(segmentation_mask: np.ndarray, class_colors: dict [ str , RGB ], add_background_class: bool = False) -> Iterator[tuple[str, np.ndarray]]: Iterator[tuple[str, np.ndarray]]
Helper function to convert an RGB segmentation mask to boolean masks for each class.  Example:      >>> segmentation_mask = np.array([     ...     [[0, 0, 0], [255, 0, 0], [0, 255, 0]],     ...     [[0, 0, 0], [0, 255, 0], [0, 0, 255]],     ...     ], dtype=np.uint8)     >>> class_colors = {     ...     "red": (255, 0, 0),     ...     "green": (0, 255, 0),     ...     "blue": (0, 0, 255),     ... }     >>> for class_name, mask in rgb_to_bool_masks(     ...     segmentation_mask,     ...     class_colors,     ...     add_background_class=True,     ... ):     ...     print(class_name, np.array2string(mask, separator=", "))     background [[ True, False, False],                 [ True, False, False]]     red        [[False,  True, False],                 [False, False, False]]     green      [[False, False,  True],                 [False, True, False]]     blue       [[False, False, False],                 [False, False,  True]]  @type segmentation_mask: npt.NDArray[np.uint8] @param segmentation_mask: An RGB segmentation mask where each pixel     is colored according to the class it belongs to. @type class_colors: Dict[str, Tuple[int, int, int]] @param class_colors: A dictionary mapping class names to RGB colors. @type add_background_class: bool @param add_background_class: Whether to add a background class with a mask for all pixels     that do not belong to any class. The class name will be set to "background".     The background class will be yielded first. Default is False. @rtype: Iterator[Tuple[str, npt.NDArray[np.bool_]]] @return: An iterator of tuples where the first element is the class name and     the second element is a boolean mask for that class.
function
warn_on_duplicates(df: pl.LazyFrame)
Logs warnings for duplicate UUIDs and annotations in the dataset.  @type df: pl.LazyFrame @param df: Polars lazy frame containing dataset information.
class
class
function
plot_class_distribution(ax: plt.Axes, task_type: str, task_data: list [ dict [ str , Any ] ])
Plots a bar chart of class distribution.  @type ax: plt.Axes @param ax: The axis to plot on. @type task_type: str @param task_type: The type of task. @type task_data: List[Dict[str, Any]] @param task_data: The task data to plot.
function
plot_heatmap(ax: plt.Axes, fig: plt.Figure, task_type: str, heatmap_data: list [ list [ float ] ] | None)
" Plots a heatmap of heatmap_data.  @type ax: plt.Axes @param ax: The axis to plot on. @type fig: plt.Figure @param fig: The figure to plot on. @type task_type: str @param task_type: The type of task. @type heatmap_data: Optional[List[List[float]]] @param heatmap_data: The heatmap data to plot.
function
get_task_name(task: str) -> str: str
Returns the task name from a task.  @type task: str @param task: The task. @rtype: str @return: The task name.
function
get_task_type(task: str) -> str: str
Returns the task type from a task.  Example:      >>> get_task_type("task_name/type")     'type'     >>> get_task_type("metadata/name")     'metadata/name'     >>> get_task_type("task_name/metadata/name")     'metadata/name'  @type task: str @param task: The task in a format like "task_name/type". @rtype: str @return: The task type. If the task is a metadata task,     the type will be "metadata/type".
function
split_task(task: str) -> tuple[str, str]: tuple[str, str]
Splits a task into its task name and type.  @type task: str @param task: The task to split. @rtype: Tuple[str, str] @return: A tuple containing the task name and type.
function
task_is_metadata(task: str) -> bool: bool
Returns whether a task is a metadata task.  @type task: str @param task: The task to check. @rtype: bool @return: Whether the task is a metadata task.
function
task_type_iterator(labels: Labels, task_type: TaskType) -> Iterator[tuple[str, np.ndarray]]: Iterator[tuple[str, np.ndarray]]
Iterates over labels of a specific type.  @type labels: Labels @param labels: The labels to iterate over. @type task_type: str @param task_type: The type of label to iterate over. @rtype: Iterator[Tuple[str, np.ndarray]] @return: An iterator over the labels of the specified type.
module

luxonis_ml.data.utils.constants

module

luxonis_ml.data.utils.plot_utils

module

luxonis_ml.data.utils.visualizations

class
ColorMap
A mapping that assigns distinct RGB colors to hashable labels.  The ColorMap class generates and stores distinct colors for any hashable labels. Colors are lazily assigned upon request using a distinct_color_generator.
function
distinct_color_generator(stop: int = -1) -> Generator[RGB, None, None]: Generator[RGB, None, None]
Generate distinct RGB colors using the golden ratio.  This generator produces a sequence of distinct colors in RGB format. The colors are generated by incrementing the hue by the golden ratio and keeping saturation and value fixed. This ensures a wide distribution of visually distinct colors.  @param stop: Optional. The maximum number of colors to generate. If     set to -1 (default), the generator will continue indefinitely. @type stop: int @yield: A tuple representing an RGB color, where each component (R,     G, B) is an integer in the range [0, 255]. @rtype: Generator[tuple[int, int, int], None, None]
function
resolve_color(color: Color) -> RGB: RGB
Resolves a color to an RGB tuple.  @type color: Color @param color: The color to resolve. Can be a string, an integer or a     tuple. @rtype: Tuple[int, int, int] @return: The RGB tuple.
function
rgb_to_hsv(color: Color) -> HSV: HSV
Converts an RGB color to HSV.  @type color: Color @param color: The color to convert. @rtype: Tuple[float, float, float] @return: The HSV tuple.
function
hsv_to_rgb(color: HSV) -> RGB: RGB
Converts an HSV color to RGB.  @type color: Tuple[float, float, float] @param color: The color to convert as an HSV tuple. @rtype: Tuple[int, int, int] @return: The RGB tuple.
function
get_contrast_color(color: Color) -> RGB: RGB
Returns a contrasting color for the given RGB color.  @type color: Color @param color: The color to contrast. @rtype: Tuple[int, int, int] @return: The contrasting color.
function
str_to_rgb(string: str) -> RGB: RGB
Converts a string to its unique RGB color.  @type string: str @param string: The string to convert. @rtype: Tuple[int, int, int] @return: The RGB tuple.
function
draw_dashed_rectangle(image: np.ndarray, pt1: tuple [ int , int ], pt2: tuple [ int , int ], color: Color, thickness: int = 1, dash_length: int = 10)
Draws a dashed rectangle on the image.  @type image: np.ndarray @param image: The image to draw on. @type pt1: Tuple[int, int] @param pt1: The top-left corner of the rectangle. @type pt2: Tuple[int, int] @param pt2: The bottom-right corner of the rectangle. @type color: Color @param color: The color of the rectangle. @type thickness: int @param thickness: The thickness of the rectangle. Default is 1. @type dash_length: int @param dash_length: The length of the dashes. Default is 10.
function
draw_cross(img: np.ndarray, center: tuple [ int , int ], size: int = 5, color: Color = 0, thickness: int = 1)
Draws a cross on the image.  @type img: np.ndarray @param img: The image to draw on. @type center: Tuple[int, int] @param center: The center of the cross. @type size: int @param size: The size of the cross. Default is 5. @type color: Color @param color: The color of the cross. Default is black. @type thickness: int @param thickness: The thickness of the cross. Default is 1.
function
create_text_image(text: str, width: int, height: int, font_size: float = 0.7, bg_color: Color = 255, text_color: Color = 0) -> np.ndarray: np.ndarray
Creates an image with the given text centered in the image.  @type text: str @param text: The text to display. @type width: int @param width: The width of the image. @type height: int @param height: The height of the image. @type font_size: float @param font_size: The font size of the text. Default is 0.7. @type bg_color: Tuple[int, int, int] @param bg_color: The background color of the image. Default is     white. @type text_color: Tuple[int, int, int] @param text_color: The color of the text. Default is black.
function
concat_images(image_dict: dict [ str , np.ndarray ], padding: int = 10, label_height: int = 30) -> np.ndarray: np.ndarray
Concatenates images into a single image with labels.  It will attempt to create a square grid of images.  @type image_dict: Dict[str, np.ndarray] @param image_dict: A dictionary mapping image names to images. @type padding: int @param padding: The padding between images. Default is 10. @type label_height: int @param label_height: The height of the label. Default @rtype: np.ndarray @return: The concatenated image.
function
draw_bbox_label(image: np.ndarray, class_name: str, box: np.ndarray, color: tuple [ int , int , int ], font_scale: float)
Draws the classname label at the top-left corner of the bounding box.  @type image: np.ndarray @param image: The image to draw on. @type class_name: str @param class_name: The name of the class. @type box: np.ndarray @param box: The bounding box coordinates. The format is [class_id,     x1, y1, x2, y2], where (x1, y1) is the top-left corner and (x2,     y2) is the bottom-right corner. @type color: Tuple[int, int, int] @param color: The color of the label. @type font_scale: float @param font_scale: The scale of the font.
function
draw_keypoint_label(image: np.ndarray, text: str, point: tuple [ int , int ], size: int, color: tuple [ int , int , int ], font_scale: float)
Draws a text label next to a keypoint on the image.  @type image: np.ndarray @param image: The image to draw on. @type text: str @param text: The text to draw. @type point: Tuple[int, int] @param point: The coordinates of the keypoint. @type size: int @param size: The size of the keypoint. @type color: Tuple[int, int, int] @param color: The color of the text. @type font_scale: float
function
visualize(image: np.ndarray, source_name: str, labels: Labels, classes: dict [ str , dict [ str , int ] ], blend_all: bool = False) -> np.ndarray: np.ndarray
Visualizes the labels on the image.  @type image: np.ndarray @param image: The image to visualize. @type source_name: str @param source_name: The name of the source of the image. @type labels: Labels @param labels: The labels to visualize. @type class_names: Dict[str, List[str]] @param class_names: A dictionary mapping task names to a list of     class names. @type blend_all: bool @param blend_all: Whether to blend all labels (apart from semantic     segmentations) into a single image. This means mixing labels     belonging to different tasks. Default is False. @rtype: np.ndarray @return: The visualized image.
class

luxonis_ml.data.utils.visualizations.ColorMap(collections.abc.Mapping)

class

luxonis_ml.data.utils.ParquetFileManager

method
__init__(self, directory: PathType, num_rows: int = 100000)
Manages the insertion of data into parquet files.  @type directory: str @param directory: The local directory in which parquet files are     stored. @type num_rows: int @param num_rows: The maximum number of rows permitted in a     parquet file before another file is created.
variable
variable
variable
variable
variable
variable
variable
method
write(self, uuid: str, data: ParquetRecord, group_id: str)
Writes a row to the current working parquet file.  @type uuid: str @param uuid: A unique identifier for the row, typically a UUID. @type data: Dict @param data: A dictionary representing annotations, mapping     annotation types to values. @type group_id: str @param group_id: An unique identifier for the group to which the     row belongs.
method
method
method
class

luxonis_ml.data.utils.ParquetRecord(typing.TypedDict)

class

luxonis_ml.data.BucketStorage(enum.Enum)

constant
constant
constant
constant
class

luxonis_ml.data.BucketType(enum.Enum)

class

luxonis_ml.data.ImageType(enum.Enum)

constant
constant
constant
class

luxonis_ml.data.MediaType(enum.Enum)

constant
constant
constant
package

luxonis_ml.enums

module
class
class

luxonis_ml.enums.DatasetType(str, enum.Enum)

constant
constant
constant
constant
constant
constant
constant
constant
constant
constant
constant
constant
package

luxonis_ml.nn_archive

module
module
package
module
module
class
ArchiveGenerator
Generator of abstracted NN archive (.tar) files containing config and model files (executables).
class
Config
The main class of the multi/single-stage model config scheme (multi- stage models consists of interconnected single-stage models).
class
Model
Class defining a single-stage model config scheme.
function
infer_layout(shape: list [ int ]) -> str: str
Infers a layout for the given shape.  Tries to guess most common layouts for the given shape pattern. Otherwise, uses the first free letter of the alphabet for each dimension.  Example::     >>> make_default_layout([1, 3, 256, 256])     >>> "NCHW"     >>> make_default_layout([1, 19, 7, 8])     >>> "NABC"
function
is_nn_archive(path: PathType) -> bool: bool
Check if the given path is a valid NN archive file.  @type path: PathType @param path: Path to the file to check. @rtype: bool @return: True if the file is a valid NN archive file, False     otherwise.
module

luxonis_ml.nn_archive.config

package

luxonis_ml.nn_archive.config_building_blocks

package
package
package

luxonis_ml.nn_archive.config_building_blocks.base_models

module
module
module
module
module
class
Head
Represents head of a model.
class
HeadMetadata
Metadata for the basic head. It allows you to specify additional fields.
class
Input
Represents input stream of a model.
class
PreprocessingBlock
Represents preprocessing operations applied to the input data.
class
Metadata
Represents metadata of a model.
class
Output
Represents output stream of a model.
module

luxonis_ml.nn_archive.config_building_blocks.base_models.head_metadata

class
HeadObjectDetectionMetadata
Metadata for the object detection head.
class
HeadObjectDetectionSSDMetadata
Metadata for the SSD object detection head.
class
HeadClassificationMetadata
Metadata for the classification head.
class
HeadSegmentationMetadata
Metadata for the segmentation head.
class
HeadYOLOMetadata
Metadata for the YOLO head.
class

luxonis_ml.nn_archive.config_building_blocks.base_models.head_metadata.HeadObjectDetectionMetadata(luxonis_ml.nn_archive.config_building_blocks.base_models.HeadMetadata)

variable
classes
Names of object classes detected by the model.
variable
n_classes
Number of object classes detected by the model.
variable
iou_threshold
Non-max supression threshold limiting boxes intersection.
variable
conf_threshold
Confidence score threshold above which a detected object is considered valid.
variable
max_det
Maximum detections per image.
variable
anchors
Predefined bounding boxes of different sizes and aspect ratios. The innermost lists are length 2 tuples of box sizes. The middle lists are anchors for each output. The outmost lists go from smallest to largest output.
class

luxonis_ml.nn_archive.config_building_blocks.base_models.head_metadata.HeadObjectDetectionSSDMetadata(luxonis_ml.nn_archive.config_building_blocks.base_models.head_metadata.HeadObjectDetectionMetadata)

variable
boxes_outputs
Output name corresponding to predicted bounding box coordinates.
variable
scores_outputs
Output name corresponding to predicted bounding box confidence scores.
class

luxonis_ml.nn_archive.config_building_blocks.base_models.head_metadata.HeadClassificationMetadata(luxonis_ml.nn_archive.config_building_blocks.base_models.HeadMetadata)

variable
classes
Names of object classes classified by the model.
variable
n_classes
Number of object classes classified by the model.
variable
is_softmax
True, if output is already softmaxed
class

luxonis_ml.nn_archive.config_building_blocks.base_models.head_metadata.HeadSegmentationMetadata(luxonis_ml.nn_archive.config_building_blocks.base_models.HeadMetadata)

variable
classes
Names of object classes segmented by the model.
variable
n_classes
Number of object classes segmented by the model.
variable
is_softmax
True, if output is already softmaxed
class

luxonis_ml.nn_archive.config_building_blocks.base_models.head_metadata.HeadYOLOMetadata(luxonis_ml.nn_archive.config_building_blocks.base_models.head_metadata.HeadObjectDetectionMetadata, luxonis_ml.nn_archive.config_building_blocks.base_models.head_metadata.HeadSegmentationMetadata)

variable
yolo_outputs
A list of output names for each of the different YOLO grid sizes.
variable
mask_outputs
A list of output names for each mask output.
variable
protos_outputs
Output name for the protos.
variable
keypoints_outputs
A list of output names for the keypoints.
variable
angles_outputs
A list of output names for the angles.
variable
subtype
YOLO family decoding subtype (e.g. yolov5, yolov6, yolov7 etc.)
variable
n_prototypes
Number of prototypes per bbox in YOLO instance segmnetation.
variable
n_keypoints
Number of keypoints per bbox in YOLO keypoint detection.
variable
is_softmax
True, if output is already softmaxed in YOLO instance segmentation
CLASS_METHOD
class

luxonis_ml.nn_archive.config_building_blocks.base_models.Head(pydantic.BaseModel, abc.ABC)

variable
name
Optional name of the head.
variable
parser
Name of the parser responsible for processing the models output.
variable
outputs
Specify which outputs are fed into the parser. If None, all outputs are fed.
variable
metadata
Metadata of the parser.
class

luxonis_ml.nn_archive.config_building_blocks.base_models.HeadMetadata(pydantic.BaseModel)

variable
postprocessor_path
Path to the postprocessor.
variable
class

luxonis_ml.nn_archive.config_building_blocks.base_models.Input(luxonis_ml.utils.BaseModelExtraForbid)

variable
name
Name of the input layer.
variable
dtype
Data type of the input data (e.g., 'float32').
variable
input_type
Type of input data (e.g., 'image').
variable
shape
Shape of the input data as a list of integers (e.g. [H,W], [H,W,C], [N,H,W,C], ...).
variable
layout
Lettercode interpretation of the input data dimensions (e.g., 'NCHW').
variable
preprocessing
Preprocessing steps applied to the input data.
method
static method
class

luxonis_ml.nn_archive.config_building_blocks.base_models.PreprocessingBlock(luxonis_ml.utils.BaseModelExtraForbid)

variable
mean
Mean values in channel order. Order depends on the order in which the model was trained on.
variable
scale
Standardization values in channel order. Order depends on the order in which the model was trained on.
variable
reverse_channels
If True input to the model is RGB else BGR.
variable
interleaved_to_planar
If True input to the model is interleaved (NHWC) else planar (NCHW).
variable
dai_type
DepthAI input type which is read by DepthAI to automatically setup the pipeline.
class

luxonis_ml.nn_archive.config_building_blocks.base_models.Metadata(pydantic.BaseModel)

variable
name
Name of the model.
variable
path
Relative path to the model executable.
variable
class

luxonis_ml.nn_archive.config_building_blocks.base_models.Output(luxonis_ml.utils.BaseModelExtraForbid)

variable
name
Name of the output layer.
variable
dtype
Data type of the output data (e.g., 'float32').
variable
variable
method
method
package

luxonis_ml.nn_archive.config_building_blocks.enums

module
module
class
DataType
Represents all existing data types used in i/o streams of the model.
class
InputType
Represents a type of input the model is expecting.
class

luxonis_ml.nn_archive.config_building_blocks.enums.DataType(enum.Enum)

constant
constant
constant
constant
constant
constant
constant
constant
constant
constant
constant
constant
constant
constant
constant
class

luxonis_ml.nn_archive.config_building_blocks.enums.InputType(enum.Enum)

constant
constant
class

luxonis_ml.nn_archive.ArchiveGenerator

variable
archive_name
Desired archive file name.
variable
save_path
Path to where we want to save the archive file.
variable
cfg_dict
Archive configuration dict.
variable
executables_paths
Paths to relevant model executables.
variable
compression
Type of archive file compression ("xz" for LZMA, "gz" for gzip, or "bz2" for bzip2 compression).
method
variable
method
make_archive(self) -> Path: Path
Run NN archive (.tar) file generation.
class

luxonis_ml.nn_archive.Config(luxonis_ml.utils.BaseModelExtraForbid)

variable
config_version
String representing config schema version in format 'x.y' where x is major version and y is minor version
variable
model
A Model object representing the neural network used in the archive.
CLASS_METHOD
class

luxonis_ml.nn_archive.Model(luxonis_ml.utils.BaseModelExtraForbid)

variable
metadata
Metadata object defining the model metadata.
variable
inputs
List of Input objects defining the model inputs.
variable
outputs
List of Output objects defining the model outputs.
variable
heads
List of Head objects defining the model heads. If not defined, we assume a raw output.
package

luxonis_ml.tracker

module

luxonis_ml.tracker.mlflow_plugins

class

luxonis_ml.tracker.LuxonisRequestHeaderProvider(mlflow.tracking.request_header.abstract_request_header_provider.RequestHeaderProvider)

class

luxonis_ml.tracker.LuxonisTracker

method
__init__(self, project_name: str | None = None, project_id: str | None = None, run_name: str | None = None, run_id: str | None = None, save_directory: PathType = 'output', is_tensorboard: bool = False, is_wandb: bool = False, is_mlflow: bool = False, is_sweep: bool = False, wandb_entity: str | None = None, mlflow_tracking_uri: str | None = None, rank: int = 0)
Implementation of PytorchLightning Logger that wraps various logging software. Supported loggers: TensorBoard, WandB and MLFlow.  @type project_name: Optional[str] @param project_name: Name of the project used for WandB and MLFlow.     Defaults to None.  @type project_id: Optional[str] @param project_id: Project id used for WandB and MLFlow.     Defaults to None.  @type run_name: Optional[str] @param run_name: Name of the run, if None then auto-generate random name.     Defaults to None.  @type run_id: Optional[str] @param run_id: Run id used for continuing MLFlow run.     Defaults to None.  @type save_directory: str @param save_directory: Path to save directory.     Defaults to "output".  @type is_tensorboard: bool @param is_tensorboard: Wheter use TensorBoard logging.     Defaults to False.  @type is_wandb: bool @param is_wandb: Wheter use WandB logging.     Defaults to False.  @type is_mlflow: bool @param is_mlflow: Wheter use MLFlow logging.     Defaults to False.  @type is_sweep: bool @param is_sweep: Wheter current run is part of a sweep.     Defaults to False.  @type wandb_entity: Optional[str] @param wandb_entity: WandB entity to use.     Defaults to None.  @type mlflow_tracking_uri: Optional[str] @param mlflow_tracking_uri: MLFlow tracking uri to use.     Defaults to None.  @type rank: int @param rank: Rank of the process, used when running on multiple threads.     Defaults to 0.
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
static method
LuxonisTracker.rank_zero_only(fn: Callable) -> Callable: Callable
Function wrapper that lets only processes with rank=0 execute it.
method
log_to_mlflow(self, log_fn: Callable, args, kwargs)
Attempts to log to MLflow, with retries.  Logs locally if failures persist.
method
store_log_locally(self, log_fn: Callable, args, kwargs)
Stores log data locally if logging to MLflow fails.
method
log_stored_logs_to_mlflow(self)
Attempts to log any data stored in local_logs to MLflow.
method
save_logs_locally(self)
Saves metrics, parameters, images, artifacts, and matrices locally.
property
name
Returns run name.
property
version
Returns tracker's version.
property
experiment
Creates new experiments or returns active ones if already created.
method
log_hyperparams(self, params: dict [ str , ( str | bool | int | float | None ) ])
Logs hyperparameter dictionary.  @type params: Dict[str, Union[str, bool, int, float, None]] @param params: Dict of hyperparameters key-value pairs.
method
log_metric(self, name: str, value: float, step: int)
Logs metric value with name and step.  @note: step is ommited when logging with wandb to avoid problems     with inconsistent incrementation. @type name: str @param name: Metric name @type value: float @param value: Metric value @type step: int @param step: Current step
method
log_metrics(self, metrics: dict [ str , float ], step: int)
Logs metric dictionary.  @type metrics: Dict[str, float] @param metrics: Dict of metric key-value pairs @type step: int @param step: Current step
method
log_image(self, name: str, img: np.ndarray, step: int)
Logs image with name and step. Note: step is omitted when logging with wandb is used to avoid problems with inconsistent incrementation.  @type name: str @param name: Caption of the image @type img: np.ndarray @param img: Image data @type step: int @param step: Current step
method
upload_artifact(self, path: PathType, name: str | None = None, typ: str = 'artifact')
Uploads artifact to the logging service.  @type path: PathType @param path: Path to the artifact @type name: Optional[str] @param name: Name of the artifact, if None then use the name of     the file @type typ: str @param typ: Type of the artifact, defaults to "artifact". Only     used for WandB.
method
upload_artifact_to_mlflow(self, path: PathType, name: str | None = None)
Uploads artifact specifically to MLflow.  @type path: PathType @param path: Path to the artifact @type name: Optional[str] @param name: Name of the artifact, if None then use the name of     the file
method
log_matrix(self, matrix: np.ndarray, name: str, step: int)
Logs matrix to the logging service.  @type matrix: np.ndarray @param matrix: The matrix to log. @type name: str @param name: The name used to log the matrix. @type step: int @param step: The current step.
method
log_images(self, imgs: dict [ str , np.ndarray ], step: int)
Logs multiple images.  @type imgs: Dict[str, np.ndarray] @param imgs: Dict of image key-value pairs where key is image     caption and value is image data @type step: int @param step: Current step
method
close(self)
Finalizes logging and saves unsent logs locally.
module

luxonis_ml.typing

type alias
PathType: TypeAlias
A string or a `pathlib.Path` object.
type alias
PosixPathType: TypeAlias
A string or a `pathlib.PurePosixPath` object.
type alias
type alias
Labels: TypeAlias
Dictionary mappping task names to the annotations as C{np.ndarray}
type alias
LoaderSingleOutput: TypeAlias
C{LoaderSingleOutput} is a tuple containing a single image as a C{np.ndarray} and a dictionary of task group names and their annotations as L{Labels}.
type alias
LoaderMultiOutput: TypeAlias
C{LoaderMultiOutput} is a tuple containing a dictionary mapping image names to C{np.ndarray} and a dictionary of task group names and their annotations as L{Labels}.
type alias
LoaderOutput: TypeAlias
C{LoaderOutput} is a tuple containing either a single image as a C{np.ndarray} or a dictionary mapping image names to C{np.ndarray}, along with a dictionary of task group names and their annotations as L{Annotations}.
type alias
type alias
type alias
Color: TypeAlias
Color type alias.  Can be either a string (e.g. "red", "#FF5512"),  a tuple of RGB values, or a single value (in which case it is interpreted as a grayscale value).
type alias
PrimitiveType: TypeAlias
Primitive types in Python.
type alias
type alias
Params: TypeAlias
A keyword dictionary of additional parameters.  Usually loaded from a YAML file.
type alias
Kwargs: TypeAlias
A keyword dictionary of arbitrary parameters.
class
ConfigItem
Configuration schema for dynamic object instantiation. Typically used to instantiate objects stored in registries.  A dictionary with a name and a dictionary of parameters.
type variable
function
check_type(value: Any, type_: type [ T ]) -> TypeGuard[T]: TypeGuard[T]
Checks if the value has the correct type.  @type value: Any @param value: The value to check. @type type_: Type[K] @param type_: The type to check against. @rtype: bool @return: C{True} if the value has the correct type, C{False}     otherwise.
function
all_not_none(values: Iterable [ Any ]) -> bool: bool
Checks if none of the values in the iterable is C{None}  @type values: Iterable[Any] @param values: An iterable of values @rtype: bool @return: C{True} if all values are not C{None}, C{False} otherwise
function
any_not_none(values: Iterable [ Any ]) -> bool: bool
Checks if at least one value in the iterable is not C{None}  @type values: Iterable[Any] @param values: An iterable of values @rtype: bool @return: C{True} if at least one value is not C{None}, C{False}     otherwise
class

luxonis_ml.typing.ConfigItem(pydantic.BaseModel)

variable
name
The name of the object this configuration applies to. Required.
variable
params
Additional parameters for instantiating the object. Not required.
package

luxonis_ml.utils

module
module
module
module
module
module
module
module
class
LuxonisConfig
Class for storing configuration.
constant
class
function
is_acyclic(graph: dict [ str , list [ str ] ]) -> bool: bool
Tests if graph is acyclic.  @type graph: dict[str, list[str]] @param graph: Graph in a format of a dictionary of predecessors. @rtype: bool @return: True if graph is acyclic, False otherwise.
function
traverse_graph(graph: dict [ str , list [ str ] ], nodes: Mapping [ str , T ]) -> Iterator[tuple[str, T, list[str], list[str]]]: Iterator[tuple[str, T, list[str], list[str]]]
Traverses the graph in topological order, starting from the nodes with no predecessors.  Example:      >>> graph = {"a": ["b"], "b": []}     >>> nodes = {"a": 1, "b": 2}     >>> for name, value, preds, rem in traverse_graph(graph, nodes):     ...     print(name, value, preds, rem)     b 2 [] ['a']     a 1 ['b'] []  @type graph: dict[str, list[str]] @param graph: Graph in a format of a dictionary of predecessors.     Keys are node names, values are node predecessors (list of node     names). @type nodes: dict[str, T] @param nodes: Dictionary mapping node names to values. @rtype: Iterator[tuple[str, T, list[str], list[str]]] @return: Iterator of tuples containing node name, node value, node     predecessors, and remaining unprocessed nodes. @raises RuntimeError: If the graph is malformed.
function
deprecated(args: str, suggest: dict [ str , str ] | None = None, additional_message: str | None = None, altogether: bool = False) -> Callable[[Callable], Callable]: Callable[[Callable], Callable]
Decorator to mark a function or its parameters as deprecated.  Example:      >>> @deprecated("old_arg",     ...             "another_old_arg",     ...             suggest={"old_arg": "new_arg"},     ...             additional_message="Usage of 'old_arg' is discouraged.")     ...def my_func(old_arg, another_old_arg, new_arg=None):     ...   pass     >>> my_func("foo")     >>> # DeprecationWarning: Argument 'old_arg'     ... # in function `my_func` is deprecated and     ... # will be removed in future versions.     ... # Use 'new_arg' instead.     ... # Usage of 'old_arg' is discouraged.  @type args: str @param args: The names of the deprecated parameters. @type suggest: Dict[str, str] @param suggest: Suggested replacement parameters. @type additional_message: str @param additional_message: Additional message to display.     If provided, it will be appended to the warning message. @type altogether: bool @param altogether: If True, the whole function is     marked as deprecated. Defaults to False.
function
log_once(logger: Callable [ [ str ] , None ], message: str)
Logs a message only once.  @type logger: Logger @param logger: The logger to use. @type message: str @param message: The message to log.
function
setup_logging(level: Literal [ ' DEBUG ' , ' INFO ' , ' WARNING ' , ' ERROR ' , ' CRITICAL ' ] | None = None, file: PathType | None = None, use_rich: bool = True, kwargs)
Sets up global logging using loguru and rich.  @type level: Optional[str] @param level: Logging level. If not set, reads from the environment     variable C{LOG_LEVEL}. Defaults to "INFO". @type file: Optional[str] @param file: Path to the log file. If provided, logs will be saved     to this file. @type use_rich: bool @param use_rich: If True, uses rich for logging. Defaults to True. @type kwargs: Any @param kwargs: Additional keyword arguments to pass to     C{RichHandler}.
class
class
AutoRegisterMeta
Metaclass for automatically registering modules.  Can be set as a metaclass for abstract base classes. Then, all subclasses will be automatically registered under the name of the subclass.  Example:  >>> REGISTRY = Registry(name="modules") >>> class BaseClass(metaclass=AutoRegisterMeta, registry=REGISTRY): ...     pass >>> class SubClass(BaseClass): ...     pass >>> REGISTRY.get("SubClass") <class '__main__.SubClass'> >>> BaseClass.REGISTRY.get("SubClass") <class '__main__.SubClass'>
class
function
module

luxonis_ml.utils.config

type variable
module

luxonis_ml.utils.filesystem

class
class
class

luxonis_ml.utils.filesystem.FSType(enum.Enum)

constant
constant
module

luxonis_ml.utils.graph

type variable
module

luxonis_ml.utils.logging

module

luxonis_ml.utils.registry

type variable
class

luxonis_ml.utils.LuxonisConfig(luxonis_ml.utils.BaseModelExtraForbid)

CLASS_METHOD
get_config
Loads config from a yaml file or a dictionary.  @type cfg: Optional[Union[str, dict]] @param cfg: Path to config file or a dictionary. @type overrides: Optional[Union[dict, list[str], tuple[str, ...]]] @param overrides: List of CLI overrides in a form of a dictionary mapping     "dotted" keys to unparsed string or python values. @rtype: LuxonisConfig @return: Instance of the config class. @raise ValueError: If neither C{cfg} nor C{overrides} are provided.
method
method
method
get_json_schema(self) -> Params: Params
Retuns dict representation of the config json schema.  @rtype: dict @return: Dictionary with config json schema.
method
save_data(self, path: PathType)
Saves config to a yaml file.  @type path: str @param path: Path to output yaml file.
method
get(self, key_merged: str, default: Any = None) -> Any: Any
Returns a value from L{Config} based on the given key.  If the key doesn't exist, the default value is returned.  @type key_merged: str @param key_merged: Key in a form of a string with levels     separated by dots. @type default: Any @param default: Default value to return if the key doesn't     exist. @rtype: Any @return: Value of the key or default value.
class

luxonis_ml.utils.LuxonisFileSystem

method
__init__(self, path: str, allow_active_mlflow_run: bool | None = False, allow_local: bool | None = True, cache_storage: str | None = None, put_file_plugin: str | None = None)
Abstraction over remote and local sources.  Helper class which abstracts uploading and downloading files from remote and local sources. Supports S3, MLflow, GCS, and local file systems.  @type path: str @param path: Input path consisting of protocol and actual path     or just path for local files @type allow_active_mlflow_run: Optional[bool] @param allow_active_mlflow_run: Flag if operations are allowed     on active MLFlow run. Defaults to False. @type allow_local: Optional[bool] @param allow_local: Flag if operations are allowed on local file     system. Defaults to True. @type cache_storage: Optional[str] @param cache_storage: Path to cache storage. No cache is used if     set to None. Defaults to None. @type put_file_plugin: Optional[str] @param put_file_plugin: The name of a registered function under     the PUT_FILE_REGISTRY to override C{self.put_file}.
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
method
put_file(self, local_path: PathType, remote_path: PosixPathType, mlflow_instance: ModuleType | None = None) -> str: str
Copy a single file to remote storage.  @type local_path: PathType @param local_path: Path to local file @type remote_path: PosixPathType @param remote_path: Relative path to remote file @type mlflow_instance: Optional[L{ModuleType}] @param mlflow_instance: MLFlow instance if uploading to active     run. Defaults to C{None}. @rtype: str @return: The full remote path of the uploded file.
property
is_mlflow
Returns True if the filesystem is MLFlow.
property
is_fsspec
Returns True if the filesystem is fsspec.
property
full_path
Returns full remote path.
method
init_fsspec_filesystem(self) -> fsspec.AbstractFileSystem: fsspec.AbstractFileSystem
Initializes L{fsspec} filesystem based on the used protocol.  @rtype: L{fsspec.AbstractFileSystem} @return: Initialized fsspec filesystem.
method
put_dir(self, local_paths: PathType | Iterable [ PathType ], remote_dir: PosixPathType, uuid_dict: dict [ str , str ] | None = None, mlflow_instance: ModuleType | None = None, copy_contents: bool = False) -> dict[str, str]|None: dict[str, str]|None
Uploads files to remote storage.  @type local_paths: Union[PathType, Sequence[PathType]] @param local_paths: Either a string specifying a directory to     walk the files or a list of files which can be in different     directories. @type remote_dir: PosixPathType @param remote_dir: Relative path to remote directory @type uuid_dict: Optional[Dict[str, str]] @param uuid_dict: Stores paths as keys and corresponding UUIDs     as values to replace the file basename. @type mlflow_instance: Optional[L{ModuleType}] @param mlflow_instance: MLFlow instance if uploading to active     run. Defaults to None. @type copy_contents: bool @param copy_contents: If True, only copy the content of the     folder specified in local_paths. Defaults to False. @rtype: Optional[Dict[str, str]] @return: When local_paths is a list, this maps local_paths to     remote_paths
method
put_bytes(self, file_bytes: bytes, remote_path: PosixPathType, mlflow_instance: ModuleType | None = None)
Uploads a file to remote storage directly from file bytes.  @type file_bytes: bytes @param file_bytes: the bytes for the file contents @type remote_path: PosixPathType @param remote_path: Relative path to remote file @type mlflow_instance: Optional[L{ModuleType}] @param mlflow_instance: MLFlow instance if uploading to active     run. Defaults to None.
method
get_file(self, remote_path: PosixPathType, local_path: PathType, mlflow_instance: ModuleType | None = None) -> Path: Path
Copy a single file from remote storage.  @type remote_path: PosixPathType @param remote_path: Relative path to remote file @type local_path: PathType @param local_path: Path to local file @type mlflow_instance: Optional[L{ModuleType}] @param mlflow_instance: MLFlow instance if uploading to active     run. Defaults to C{None}. @rtype: Path @return: Path to the downloaded file.
method
delete_file(self, remote_path: PosixPathType)
Deletes a single file from remote storage.  @type remote_path: PosixPathType @param remote_path: Relative path to remote file
method
delete_files(self, remote_paths: list [ PosixPathType ])
Deletes multiple files from remote storage.  @type remote_paths: List[PosixPathType] @param remote_paths: Relative paths to remote files
method
get_dir(self, remote_paths: PosixPathType | Iterable [ PosixPathType ], local_dir: PathType, mlflow_instance: ModuleType | None = None) -> Path: Path
Copies many files from remote storage to local storage.  @type remote_paths: Union[PosixPathType,     Sequence[PosixPathType]] @param remote_paths: Either a string specifying a directory to     walk the files or a list of files which can be in different     directories. @type local_dir: PathType @param local_dir: Path to local directory @type mlflow_instance: Optional[L{ModuleType}] @param mlflow_instance: MLFlow instance if uploading to active     run. Defaults to C{None}. @rtype: Path @return: Path to the downloaded directory.
method
delete_dir(self, remote_dir: PosixPathType = '', allow_delete_parent: bool = False)
Deletes a directory and all its contents from remote storage.  @type remote_dir: PosixPathType @param remote_dir: Relative path to remote directory. @type allow_delete_parent: bool @param allow_delete_parent: If True, allows deletion of the     parent directory.
method
walk_dir(self, remote_dir: PosixPathType, recursive: bool = True, typ: Literal [ ' file ' , ' directory ' , ' all ' ] = 'file') -> Iterator[str]: Iterator[str]
Walks through the individual files in a remote directory.  @type remote_dir: PosixPathType @param remote_dir: Relative path to remote directory @type recursive: bool @param recursive: If True, walks through the directory     recursively. @type typ: Literal["file", "directory", "all"] @param typ: Specifies the type of files to walk through.     Defaults to "file". @rtype: Iterator[str] @return: Iterator over the paths.
method
read_text(self, remote_path: PosixPathType) -> str|bytes: str|bytes
Reads a file into a string.  @type remote_path: PosixPathType @param remote_path: Relative path to remote file. @rtype: Union[str, bytes] @return: The string containing the file contents.
method
read_to_byte_buffer(self, remote_path: PosixPathType | None = None) -> BytesIO: BytesIO
Reads a file into a byte buffer.  @type remote_path: Optional[PosixPathType] @param remote_path: Relative path to remote file. @rtype: BytesIO @return: The byte buffer containing the file contents.
method
get_file_uuid(self, path: PathType, local: bool = False) -> str: str
Reads a file and returns the (unique) UUID generated from file bytes.  @type path: PathType @param path: Relative path to remote file. @type local: bool @param local: Specifies a local path as opposed to a remote     path. @rtype: str @return: The generated UUID.
method
get_file_uuids(self, paths: Iterable [ PathType ], local: bool = False) -> dict[str, str]: dict[str, str]
Computes the UUIDs for all files stored in the filesystem.  @type paths: List[PathType] @param paths: A list of relative remote paths if remote else     local paths. @type local: bool @param local: Specifies local paths as opposed to remote paths. @rtype: Dict[str, str] @return: A dictionary mapping the paths to their UUIDs
method
is_directory(self, remote_path: PosixPathType) -> bool: bool
Checks whether the given remote path is a directory.  @type remote_path: PosixPathType @param remote_path: Relative path to remote file. @rtype: bool @return: True if the path is a directory.
method
exists(self, remote_path: PosixPathType = '') -> bool: bool
Checks whether the given remote path exists.  @type remote_path: PosixPathType @param remote_path: Relative path to remote file. Defaults to ""     (root). @rtype: bool @return: True if the path exists.
static method
LuxonisFileSystem.split_full_path(path: PathType) -> tuple[str, str]: tuple[str, str]
Splits the full path into protocol and absolute path.  @type path: PathType @param path: Full path @rtype: Tuple[str, str] @return: Tuple of protocol and absolute path.
static method
LuxonisFileSystem.get_protocol(path: str) -> str: str
Extracts the detected protocol from a path.  @type path: str @param path: Full path @rtype: str @return: Protocol of the path.
static method
LuxonisFileSystem.download(url: str, dest: PathType | None) -> Path: Path
Downloads file or directory from remote storage.  Intended for downloading a single remote object, elevating the need to create an instance of L{LuxonisFileSystem}.  @type url: str @param url: URL to the file or directory @type dest: Optional[PathType] @param dest: Destination directory. If unspecified, the current     directory is used. @rtype: Path @return: Path to the downloaded file or directory.
static method
LuxonisFileSystem.upload(local_path: PathType, url: str)
Uploads file or directory to remote storage.  Intended for uploading a single local object, elevating the need to create an instance of L{LuxonisFileSystem}.  @type local_path: PathType @param local_path: Path to the local file or directory @type url: str @param url: URL to the remote file or directory @rtype: str @return: URL to the uploaded file or directory.
class

luxonis_ml.utils.BaseModelExtraForbid(pydantic.BaseModel)

class

luxonis_ml.utils.AutoRegisterMeta(abc.ABCMeta)

variable
method
__new__(cls, name: str, bases: tuple [ type , ... ], attrs: dict [ str , type ], register: bool = True, register_name: str | None = None, registry: Registry | None = None)
Automatically register the class.  @type name: str @param name: Class name  @type bases: Tuple[type, ...] @param bases: Base classes  @type attrs: Dict[str, type] @param attrs: Class attributes  @type register: bool @param register: Weather to register the class. Defaults to True.     Should be set to False for abstract base classes.  @type register_name: Optional[str] @param register_name: Name used for registration.     If unset, the class name is used. Defaults to None.  @type registry: Optional[Registry] @param registry: Registry to use for registration.     Defaults to None. Has to be set in the base class.
class

luxonis_ml.utils.Registry(typing.Generic)

method
__init__(self, name: str)
A Registry class to store and retrieve modules.  @type name: str @ivar name: Name of the registry
method
method
method
method
method
method
property
method
get(self, key: str) -> T: T
Retrieves the registry record for the key.  @type key: str @param key: Name of the registered item, I{e.g.} the class name     in string format. @rtype: type @return: Corresponding class if L{key} exists @raise KeyError: If L{key} is not in the registry
method
method
register(self, module: T | None = None, name: str | None = None, force: bool = False) -> Callable[[T], T]|None: Callable[[T], T]|None
Registers a module.  Can be used as a decorator or as a normal method:      >>> registry = Registry(name="modules")     >>> @registry.register()     ... class Foo:     ...     pass     >>> registry.get("Foo")     <class '__main__.Foo'>     >>> class Bar:     ...     pass     >>> registry.register(module=Bar)     >>> registry.get("Bar")     <class '__main__.Bar'>  @type name: Optional[str] @param name: Name of the module. If C{None}, then use class name.     Defaults to None.  @type module: Optional[type] @param module: Module class to be registered. Defaults to None.  @type force: bool @param force: Whether to override an existing class with the same name.     Defaults to False.  @rtype: Union[type, Callable[[type], type]] @return: Module class or register function if used as a decorator  @raise KeyError: Raised if class name already exists and C{force==False}