# API 参考

0.6.0

### luxonis_ml

Kind: Package

#### data

Kind: Package

##### augmentations

Kind: Package

###### albumentations_engine

Kind: Module

###### Data: TypeAlias

Kind: Type Alias

###### TargetType: TypeAlias

Kind: Type Alias

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

Kind: Class

###### use_for_resizing: bool

Kind: Class Variable

###### wrap_transform(transform: A.BaseCompose, is_pixel: bool = False)

Kind: Function

###### base_engine

Kind: Module

###### batch_compose

Kind: Module

###### batch_transform

Kind: Module

###### luxonis_ml.data.augmentations.batch_transform.BatchTransform(abc.ABC, albumentations.DualTransform)

Kind: Class

###### __init__(self, batch_size: int, kwargs)

Kind: Method

Batch transformation that combines multiple images and
associated labels into one.

@param batch_size: Batch size needed for augmentation to work
@type batch_size: int

###### batch_size

Kind: Instance Variable

###### targets

Kind: Property

###### apply(self, image_batch: List [ np.ndarray ], kwargs) -> np.ndarray: np.ndarray

Kind: Method

###### apply_to_mask(self, mask_batch: List [ np.ndarray ], kwargs) -> np.ndarray: np.ndarray

Kind: Method

###### apply_to_bboxes(self, bboxes_batch: List [ np.ndarray ], kwargs) -> np.ndarray: np.ndarray

Kind: Method

###### apply_to_keypoints(self, keypoints_batch: List [ np.ndarray ], kwargs) -> np.ndarray: np.ndarray

Kind: Method

###### apply_to_instance_mask(self, masks_batch: List [ np.ndarray ], kwargs) -> np.ndarray: np.ndarray

Kind: Method

###### apply_to_array(self, array_batch: List [ np.ndarray ], _) -> np.ndarray: np.ndarray

Kind: Method

###### apply_to_classification(self, classification_batch: List [ np.ndarray ], _) -> np.ndarray: np.ndarray

Kind: Method

###### apply_to_metadata(self, metadata_batch: List [ np.ndarray ], _) -> np.ndarray: np.ndarray

Kind: Method

###### update_params(self, params: Dict [ str , Any ], _) -> Dict[str, Any]: Dict[str, Any]

Kind: Method

###### update_params_shape(self, params: Dict [ str , Any ], data: Dict [ str , Any ]) -> Dict[str, Any]: Dict[str, Any]

Kind: Method

###### custom

Kind: Package

###### letterbox_resize

Kind: Module

###### mixup

Kind: Module

###### mosaic

Kind: Module

###### compute_mosaic4_corners(quadrant: int, out_height: int, out_width: int, in_height: int, in_width: int) -> Tuple[Tuple[int,
int, int, int], Tuple[int, int, int, int]]: Tuple[Tuple[int, int, int, int], Tuple[int, int, int, int]]

Kind: Function

###### apply_mosaic4_to_instance_masks(masks_batch: List [ np.ndarray ], out_height: int, out_width: int, x_crop: int, y_crop:
int, value: Optional [ Union [ int , float , List [ int ] , List [ float ] ] ] = None) -> np.ndarray: np.ndarray

Kind: Function

###### apply_mosaic4_to_images(image_batch: List [ np.ndarray ], out_height: int, out_width: int, x_crop: int, y_crop: int,
padding: Optional [ Union [ int , float , List [ int ] , List [ float ] ] ] = None) -> np.ndarray: np.ndarray

Kind: Function

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.

###### 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

Kind: Function

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.

###### 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

Kind: Function

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.

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

Kind: Class

###### mask_fill_value

Kind: Instance Variable

###### __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)

Kind: Method

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}.

###### height

Kind: Instance Variable

###### width

Kind: Instance Variable

###### interpolation

Kind: Instance Variable

###### image_fill_value

Kind: Instance Variable

###### targets

Kind: Property

###### update_params(self, params: Dict [ str , Any ], kwargs) -> Dict[str, Any]: Dict[str, Any]

Kind: Method

Updates augmentation parameters with the necessary metadata.

@param params: The existing augmentation parameters dictionary.
@type params: Dict[str, Any]
@param kwargs: Additional keyword arguments to add the
parameters.
@type kwargs: Any
@return: Updated dictionary containing the merged parameters.
@rtype: Dict[str, Any]

###### compute_padding(orig_height: int, orig_width: int, out_height: int, out_width: int) -> Tuple[int, int, int, int]:
Tuple[int, int, int, int]

Kind: Static Method

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.

###### apply(self, img: np.ndarray, pad_top: int, pad_bottom: int, pad_left: int, pad_right: int, _) -> np.ndarray: np.ndarray

Kind: Method

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.

###### apply_to_mask(self, img: np.ndarray, pad_top: int, pad_bottom: int, pad_left: int, pad_right: int, _) -> np.ndarray:
np.ndarray

Kind: Method

Applies letterbox augmentation to the input mask.

###### apply_to_bboxes(self, bbox: np.ndarray, pad_top: int, pad_bottom: int, pad_left: int, pad_right: int, _) -> np.ndarray:
np.ndarray

Kind: Method

Applies letterbox augmentation to the bounding box.

###### apply_to_keypoints(self, keypoint: np.ndarray, pad_top: int, pad_bottom: int, pad_left: int, pad_right: int, cols: int,
rows: int, _) -> np.ndarray: np.ndarray

Kind: Method

Applies letterbox augmentation to the keypoint.

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

Kind: Class

###### __init__(self, alpha: Union [ float , Tuple [ float , float ] ] = 0.5, keep_aspect_ratio: bool = True, p: float = 0.5)

Kind: Method

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}.

###### alpha

Kind: Instance Variable

###### resize_transform

Kind: Instance Variable

###### apply(self, image_batch: List [ np.ndarray ], image_shapes: List [ Tuple [ int , int ] ], alpha: float, _) -> np.ndarray:
np.ndarray

Kind: Method

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.

###### apply_to_mask(self, mask_batch: List [ np.ndarray ], image_shapes: List [ Tuple [ int , int ] ], alpha: float, _) ->
np.ndarray: np.ndarray

Kind: Method

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.

###### apply_to_instance_mask(self, mask_batch: List [ np.ndarray ], image_shapes: List [ Tuple [ int , int ] ], _) -> np.ndarray:
np.ndarray

Kind: Method

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.

###### apply_to_bboxes(self, bboxes_batch: List [ np.ndarray ], image_shapes: List [ Tuple [ int , int ] ], rows: int, cols: int,
_) -> np.ndarray: np.ndarray

Kind: Method

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.

###### apply_to_keypoints(self, keypoints_batch: List [ np.ndarray ], image_shapes: List [ Tuple [ int , int ] ], _) ->
np.ndarray: np.ndarray

Kind: Method

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.

###### get_params(self) -> Dict[str, Any]: Dict[str, Any]

Kind: Method

Update parameters.

@param params: Dictionary containing parameters.
@type params: Dict[str, Any]
@return: Dictionary containing updated parameters.
@rtype: Dict[str, Any]

###### get_params_dependent_on_data(self, params: Dict [ str , Any ], data: Dict [ str , Any ]) -> Dict[str, Any]: Dict[str, Any]

Kind: Method

Get parameters dependent on the targets.

@param params: Dictionary containing parameters.
@type params: Dict[str, Any]
@return: Dictionary containing parameters dependent on the
targets.
@rtype: Dict[str, Any]

###### resize(self, data: np.ndarray, shapes: List [ Tuple [ int , int ] ], target_type: Literal [ ' image ' , ' mask ' , ' bboxes
' , ' keypoints ' ], alpha: Optional [ float ] = None, kwargs) -> np.ndarray: np.ndarray

Kind: Method

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

Kind: Class

###### __init__(self, out_height: int, out_width: int, value: Optional [ Union [ int , float , List [ int ] , List [ float ] ] ] =
None, mask_value: Optional [ Union [ int , float , List [ int ] , List [ float ] ] ] = None, p: float = 0.5)

Kind: Method

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}.

###### out_height

Kind: Instance Variable

###### out_width

Kind: Instance Variable

###### value

Kind: Instance Variable

###### mask_value

Kind: Instance Variable

###### generate_random_crop_center(self) -> Tuple[int, int]: Tuple[int, int]

Kind: Method

Generate a random crop center within the bounds of the mosaic
image size.

###### apply(self, image_batch: List [ np.ndarray ], x_crop: int, y_crop: int, _) -> np.ndarray: np.ndarray

Kind: Method

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.

###### apply_to_mask(self, mask_batch: List [ np.ndarray ], x_crop: int, y_crop: int, cols: int, rows: int, _) -> np.ndarray:
np.ndarray

Kind: Method

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.

###### apply_to_instance_mask(self, masks_batch: List [ np.ndarray ], x_crop: int, y_crop: int, _) -> np.ndarray: np.ndarray

Kind: Method

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.

###### 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

Kind: Method

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.

###### 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

Kind: Method

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.

###### get_params_dependent_on_data(self, params: Dict [ str , Any ], data: Dict [ str , Any ]) -> Dict[str, Any]: Dict[str, Any]

Kind: Method

Get parameters dependent on the targets.

@type params: Dict[str, Any]
@param params: Dictionary containing parameters.
@rtype: Dict[str, Any]
@return: Dictionary containing parameters dependent on the
targets.

###### TRANSFORMATIONS: Registry[Type[A.BasicTransform]]

Kind: Constant

###### utils

Kind: Module

###### preprocess_mask(seg: np.ndarray) -> np.ndarray: np.ndarray

Kind: Function

###### preprocess_bboxes(bboxes: np.ndarray, bbox_counter: int) -> np.ndarray: np.ndarray

Kind: Function

###### preprocess_keypoints(keypoints: np.ndarray, height: int, width: int) -> np.ndarray: np.ndarray

Kind: Function

###### postprocess_mask(mask: np.ndarray) -> np.ndarray: np.ndarray

Kind: Function

###### postprocess_bboxes(bboxes: np.ndarray) -> Tuple[np.ndarray, np.ndarray]: Tuple[np.ndarray, np.ndarray]

Kind: Function

###### postprocess_keypoints(keypoints: np.ndarray, bboxes_ordering: np.ndarray, image_height: int, image_width: int, n_keypoints:
int) -> np.ndarray: np.ndarray

Kind: Function

###### T

Kind: Type Variable

###### yield_batches(data_batch: List [ Dict [ str , T ] ], batch_size: int) -> Iterator[Dict[str, List[T]]]: Iterator[Dict[str,
List[T]]]

Kind: Function

Yield batches of data.

@type data_batch: List[Dict[str, Any]]
@param data_batch: List of dictionaries containing data.
@type batch_size: int
@param batch_size: Size of the batch.
@rtype: Iterator[Dict[str, List[Any]]]
@return: Generator of batches of data.

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

Kind: Class

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 any 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:
...

###### __init__(self, height: int, width: int, targets: Dict [ str , str ], config: Iterable [ Params ], keep_aspect_ratio: bool =
True, is_validation_pipeline: bool = False, min_bbox_visibility: float = 0.0)

Kind: Method

###### targets

Kind: Instance Variable

###### target_names_to_tasks

Kind: Instance Variable

###### image_size

Kind: Instance Variable

###### batch_transform

Kind: Instance Variable

###### spatial_transform

Kind: Instance Variable

###### pixel_transform

Kind: Instance Variable

###### resize_transform

Kind: Instance Variable

###### custom_transform

Kind: Instance Variable

###### batch_size

Kind: Property

###### apply(self, input_batch: List [ LoaderOutput ]) -> LoaderOutput: LoaderOutput

Kind: Method

###### preprocess_batch(self, labels_batch: List [ LoaderOutput ]) -> Tuple[List[Data], Dict[str, int]]: Tuple[List[Data],
Dict[str, int]]

Kind: Method

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.

###### postprocess(self, data: Data, n_keypoints: Dict [ str , int ]) -> LoaderOutput: LoaderOutput

Kind: Method

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: LoaderOutput
@return: Tuple containing the augmented image and the labels.

###### create_transformation(config: AlbumentationConfigItem) -> A.BasicTransform: A.BasicTransform

Kind: Static Method

###### task_to_target_name(task: str) -> str: str

Kind: Static Method

###### AUGMENTATION_ENGINES: Registry[Type[AugmentationEngine]]

Kind: Constant

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

Kind: Class

###### __init__(self, height: int, width: int, targets: Mapping [ str , str ], config: Iterable [ Params ], keep_aspect_ratio:
bool, is_validation_pipeline: bool, min_bbox_visibility: float = 0.0)

Kind: Method

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 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.

###### apply(self, data: List [ LoaderOutput ]) -> LoaderOutput: LoaderOutput

Kind: Method

Apply the augmentation pipeline to the data.

@type data: List[LuxonisLoaderOutput]
@param data: List of data to augment. The length of the list
must be equal to the batch size.
@rtype: LuxonisLoaderOutput
@return: Augmented data

###### batch_size

Kind: Property

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).

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

Kind: Class

###### transforms: List[BatchTransform]

Kind: Class Variable

###### __init__(self, transforms: TransformsSeqType, kwargs)

Kind: Method

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

###### batch_size

Kind: Instance Variable

###### __call__(self, data_batch: List [ Dict [ str , np.ndarray ] ]) -> Dict[str, np.ndarray]: Dict[str, np.ndarray]

Kind: Method

###### make_contiguous(data: Dict [ str , np.ndarray ]) -> Dict[str, np.ndarray]: Dict[str, np.ndarray]

Kind: Static Method

##### datasets

Kind: Package

###### annotation

Kind: Module

###### KeypointVisibility: TypeAlias

Kind: Type Alias

###### NormalizedFloat: TypeAlias

Kind: Type Alias

C{NormalizedFloat} is a float that is restricted to the range [0,
1].

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

Kind: Class

###### combine_to_numpy(annotations: List [ ClassificationAnnotation ], classes: List [ int ], n_classes: int) -> np.ndarray:
np.ndarray

Kind: Static Method

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

Kind: Class

Run-length encoded segmentation mask.

###### height

Kind: Instance Variable

The height of the segmentation mask.

###### width

Kind: Instance Variable

The width of the segmentation mask.

###### counts

Kind: Instance Variable

The run-length encoded mask. This can be a list of integers or a byte string.

###### to_numpy(self) -> np.ndarray: np.ndarray

Kind: Method

###### combine_to_numpy(annotations: List [ SegmentationAnnotation ], classes: List [ int ], n_classes: int) -> np.ndarray:
np.ndarray

Kind: Static Method

###### serialize_counts(self, counts: bytes) -> str: str

Kind: Method

###### validate_rle

Kind: Class Method

###### validate_mask

Kind: Class Method

###### validate_polyline

Kind: Class Method

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

Kind: Class

###### combine_to_numpy(annotations: List [ InstanceSegmentationAnnotation ], classes: List [ int ] = ..., n_classes: int = ...)
-> np.ndarray: np.ndarray

Kind: Static Method

###### check_valid_identifier(name: str, label: str)

Kind: Function

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.

###### base_dataset

Kind: Module

###### luxonis_dataset

Kind: Module

###### metadata

Kind: Module

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

Kind: Class

###### labels: List[str]

Kind: Class Variable

###### edges: List[Tuple[int, int]]

Kind: Class Variable

###### migration

Kind: Module

###### LDF_1_0_0_TASKS: Set[str]

Kind: Constant

###### LDF_1_0_0_TASK_TYPES: Dict[str, str]

Kind: Constant

###### luxonis_ml.data.datasets.migration.LDF_1_0_0_MetadataDict(typing_extensions.TypedDict)

Kind: Class

###### source: Dict[str, Any]

Kind: Class Variable

###### ldf_version: str

Kind: Class Variable

###### classes: Dict[str, List[str]]

Kind: Class Variable

###### tasks: Dict[str, List[str]]

Kind: Class Variable

###### skeletons: Dict[str, Skeletons]

Kind: Class Variable

###### categorical_encodings: Dict[str, Dict[str, int]]

Kind: Class Variable

###### metadata_types: Dict[str, Literal['float', 'int', 'str', 'Category']]

Kind: Class Variable

###### migrate_dataframe(df: Union [ pl.LazyFrame , pl.DataFrame ]) -> Union[pl.LazyFrame, pl.DataFrame]: Union[pl.LazyFrame,
pl.DataFrame]

Kind: Function

###### migrate_metadata(metadata: LDF_1_0_0_MetadataDict, df: Optional [ pl.LazyFrame ]) -> Metadata: Metadata

Kind: Function

###### source

Kind: Module

###### utils

Kind: Module

###### get_file(fs: LuxonisFileSystem, remote_path: PosixPathType, local_path: PathType, mlflow_instance: Optional [ ModuleType ]
= None, default: Optional [ PathType ] = None) -> Optional[Path]: Optional[Path]

Kind: Function

###### find_filepath_uuid(filepath: PathType, index: Optional [ pl.DataFrame ], raise_on_missing: bool = False) -> Optional[str]:
Optional[str]

Kind: Function

###### get_dir(fs: LuxonisFileSystem, remote_path: PosixPathType, local_dir: PathType, mlflow_instance: Optional [ ModuleType ] =
None, default: Optional [ PathType ] = None) -> Optional[Path]: Optional[Path]

Kind: Function

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

Kind: Class

Base class for an annotation.

###### combine_to_numpy(annotations: List [ Annotation ], classes: List [ int ], n_classes: int) -> np.ndarray: np.ndarray

Kind: Static Method

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

Kind: Class

A custom unspecified annotation that is an arbitrary numpy array.

All instances of this annotation must have the same shape.

###### path

Kind: Instance Variable

The path to the numpy array saved as a .npy file.

###### to_numpy(self) -> np.ndarray: np.ndarray

Kind: Method

###### combine_to_numpy(annotations: List [ ArrayAnnotation ], classes: List [ int ], n_classes: int) -> np.ndarray: np.ndarray

Kind: Static Method

###### serialize_path(self, value: FilePath) -> str: str

Kind: Method

###### validate_path

Kind: Class Method

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

Kind: Class

Bounding box annotation.

Values are normalized based on the image size.

###### x

Kind: Instance Variable

The top-left x coordinate of the bounding box. Normalized to [0, 1].

###### y

Kind: Instance Variable

The top-left y coordinate of the bounding box. Normalized to [0, 1].

###### w

Kind: Instance Variable

The width of the bounding box. Normalized to [0, 1].

###### h

Kind: Instance Variable

The height of the bounding box. Normalized to [0, 1].

###### to_numpy(self, class_id: int) -> np.ndarray: np.ndarray

Kind: Method

###### combine_to_numpy(annotations: List [ BBoxAnnotation ], classes: List [ int ], n_classes: int = ...) -> np.ndarray:
np.ndarray

Kind: Static Method

###### validate_values

Kind: Class Method

###### luxonis_ml.data.datasets.Category(str)

Kind: Class

###### __get_pydantic_core_schema__

Kind: Class Method

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

Kind: Class

###### files: Dict[str, FilePath]

Kind: Class Variable

###### annotation: Optional[Detection]

Kind: Class Variable

###### task: str

Kind: Class Variable

###### file

Kind: Property

###### validate_task_name(self) -> Self: Self

Kind: Method

###### validate_files

Kind: Class Method

###### to_parquet_rows(self) -> Iterable[ParquetRecord]: Iterable[ParquetRecord]

Kind: Method

Converts an annotation to a dictionary for writing to a
parquet file.

@rtype: L{ParquetDict}
@return: A dictionary of annotation data.

###### luxonis_ml.data.datasets.Detection(luxonis_ml.utils.BaseModelExtraForbid)

Kind: Class

###### class_name: Optional[str]

Kind: Class Variable

###### instance_id: int

Kind: Class Variable

###### metadata: Dict[str, Union[int, float, str, Category]]

Kind: Class Variable

###### boundingbox: Optional[BBoxAnnotation]

Kind: Class Variable

###### keypoints

Kind: Instance Variable

###### instance_segmentation: Optional[InstanceSegmentationAnnotation]

Kind: Class Variable

###### segmentation: Optional[SegmentationAnnotation]

Kind: Class Variable

###### array: Optional[ArrayAnnotation]

Kind: Class Variable

###### scale_to_boxes: bool

Kind: Class Variable

###### sub_detections: Dict[str, Detection]

Kind: Class Variable

###### validate_names(self) -> Self: Self

Kind: Method

###### rescale_values(self) -> Self: Self

Kind: Method

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

Kind: Class

Keypoint annotation.

Values are normalized to [0, 1] based on the image size.

###### keypoints

Kind: Instance Variable

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

###### to_numpy(self) -> np.ndarray: np.ndarray

Kind: Method

###### combine_to_numpy(annotations: List [ KeypointAnnotation ], classes: List [ int ] = ..., n_classes: int = ...) ->
np.ndarray: np.ndarray

Kind: Static Method

###### validate_values

Kind: Class Method

###### load_annotation(task_type: str, data: Dict [ str , Any ]) -> Annotation: Annotation

Kind: Function

###### DATASETS_REGISTRY: Registry[Type[BaseDataset]]

Kind: Constant

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

Kind: Class

Base abstract dataset class for managing datasets in the Luxonis MLOps ecosystem.

###### identifier

Kind: Property

The unique identifier for the dataset.

###### version

Kind: Property

The version of the underlying LDF.

###### get_tasks(self) -> Dict[str, str]: Dict[str, str]

Kind: Method

Returns a dictionary mapping task names to task types.

@rtype: Dict[str, str]
@return: A dictionary mapping task names to task types.

###### update_source(self, source: LuxonisSource)

Kind: Method

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.

###### set_classes(self, classes: Union [ List [ str ] , Dict [ str , int ] ], task: Optional [ str ] = None)

Kind: Method

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.

###### get_classes(self) -> Dict[str, List[str]]: Dict[str, List[str]]

Kind: Method

Get classes according to computer vision tasks.

@rtype: Dict[str, List[str]]
@return: A dictionary mapping tasks to the classes used in each
task.

###### set_skeletons(self, labels: Optional [ List [ str ] ] = None, edges: Optional [ List [ Tuple [ int , int ] ] ] = None,
task: Optional [ str ] = None)

Kind: Method

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.

###### get_skeletons(self) -> Dict[str, Tuple[List[str], List[Tuple[int, int]]]]: Dict[str, Tuple[List[str], List[Tuple[int,
int]]]]

Kind: Method

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.

###### add(self, generator: DatasetIterator, batch_size: int = 1000000)

Kind: Method

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.

###### make_splits(self, splits: Optional [ Union [ Dict [ str , Sequence [ PathType ] ] , Dict [ str , float ] , Tuple [ float ,
float , float ] ] ] = None, ratios: Optional [ Union [ Dict [ str , float ] , Tuple [ float , float , float ] ] ] = None,
definitions: Optional [ Dict [ str , List [ PathType ] ] ] = None, replace_old_splits: bool = False)

Kind: Method

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.

###### delete_dataset(self)

Kind: Method

Deletes all local files belonging to the dataset.

###### exists(dataset_name: str) -> bool: bool

Kind: Static Method

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

###### get_task_names(self) -> List[str]: List[str]

Kind: Method

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.

###### get_n_keypoints(self) -> Dict[str, int]: Dict[str, int]

Kind: Method

###### DatasetIterator: TypeAlias

Kind: Type Alias

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

Kind: Class

###### __init__(self, dataset_name: str, team_id: Optional [ str ] = None, bucket_type: BucketType = BucketType.INTERNAL,
bucket_storage: BucketStorage = BucketStorage.LOCAL, delete_existing: bool = False, delete_remote: bool = False)

Kind: Method

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_existing: bool
@param delete_existing: 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

###### base_path

Kind: Instance Variable

###### bucket_type

Kind: Instance Variable

###### bucket_storage

Kind: Instance Variable

###### bucket

Kind: Instance Variable

###### dataset_name

Kind: Instance Variable

###### team_id

Kind: Instance Variable

###### fs

Kind: Instance Variable

###### progress

Kind: Instance Variable

###### metadata

Kind: Property

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},
}
}

###### version

Kind: Property

###### source

Kind: Property

###### identifier

Kind: Property

###### __len__(self) -> int: int

Kind: Method

Returns the number of instances in the dataset.

###### local_path

Kind: Instance Variable

###### media_path

Kind: Instance Variable

###### annotations_path

Kind: Instance Variable

###### metadata_path

Kind: Instance Variable

###### arrays_path

Kind: Instance Variable

###### path

Kind: Instance Variable

###### clone(self, new_dataset_name: str, push_to_cloud: bool = True) -> LuxonisDataset: LuxonisDataset

Kind: Method

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.

###### sync_to_cloud(self)

Kind: Method

Uploads data to a remote cloud bucket.

###### merge_with(self, other: LuxonisDataset, inplace: bool = True, new_dataset_name: Optional [ str ] = None) -> LuxonisDataset:
LuxonisDataset

Kind: Method

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.

###### is_remote

Kind: Property

###### update_source(self, source: LuxonisSource)

Kind: Method

Updates underlying source of the dataset with a new
L{LuxonisSource}.

@type source: LuxonisSource
@param source: The new C{LuxonisSource} to replace the old one.

###### set_classes(self, classes: Union [ List [ str ] , Dict [ str , int ] ], task: Optional [ str ] = None)

Kind: Method

###### get_classes(self) -> Dict[str, Dict[str, int]]: Dict[str, Dict[str, int]]

Kind: Method

Returns a bi-directional mapping of classes to class ids for
each task.

@type: Dict[str, Dict[str, int]]

###### set_skeletons(self, labels: Optional [ List [ str ] ] = None, edges: Optional [ List [ Tuple [ int , int ] ] ] = None,
task: Optional [ str ] = None)

Kind: Method

###### get_skeletons(self) -> Dict[str, Tuple[List[str], List[Tuple[int, int]]]]: Dict[str, Tuple[List[str], List[Tuple[int,
int]]]]

Kind: Method

###### get_tasks(self) -> Dict[str, List[str]]: Dict[str, List[str]]

Kind: Method

###### get_categorical_encodings(self) -> Dict[str, Dict[str, int]]: Dict[str, Dict[str, int]]

Kind: Method

###### get_metadata_types(self) -> Dict[str, Literal['float', 'int', 'str', 'Category']]: Dict[str, Literal['float', 'int', 'str',
'Category']]

Kind: Method

###### sync_from_cloud(self, update_mode: UpdateMode = UpdateMode.IF_EMPTY)

Kind: Method

Synchronizes the dataset from a remote cloud bucket to the
local directory.

This method performs the download only if local data is empty, or always downloads
depending on the provided update_mode.

@type update_mode: UpdateMode
@param update_mode: Specifies the update behavior.
- UpdateMode.IF_EMPTY: Downloads data only if the local dataset is empty.
- UpdateMode.ALWAYS: Always downloads and overwrites the local dataset.

###### delete_dataset(self, delete_remote: bool = False)

Kind: Method

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.

###### add(self, generator: DatasetIterator, batch_size: int = 1000000) -> Self: Self

Kind: Method

###### get_splits(self) -> Optional[Dict[str, List[str]]]: Optional[Dict[str, List[str]]]

Kind: Method

###### make_splits(self, splits: Optional [ Union [ Mapping [ str , Sequence [ PathType ] ] , Mapping [ str , float ] , Tuple [
float , float , float ] ] ] = None, ratios: Optional [ Union [ Dict [ str , float ] , Tuple [ float , float , float ] ] ] = None,
definitions: Optional [ Dict [ str , List [ PathType ] ] ] = None, replace_old_splits: bool = False)

Kind: Method

###### exists(dataset_name: str, team_id: Optional [ str ] = None, bucket_storage: BucketStorage = BucketStorage.LOCAL, bucket:
Optional [ str ] = None) -> bool: bool

Kind: Static Method

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.

###### list_datasets(team_id: Optional [ str ] = None, bucket_storage: BucketStorage = BucketStorage.LOCAL, bucket: Optional [ str
] = None) -> List[str]: List[str]

Kind: Static Method

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.

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

Kind: Class

Update mode for the dataset.

###### ALWAYS: str

Kind: Constant

###### IF_EMPTY: str

Kind: Constant

###### luxonis_ml.data.datasets.Metadata(luxonis_ml.utils.pydantic_utils.BaseModelExtraForbid)

Kind: Class

###### source: Optional[LuxonisSource]

Kind: Class Variable

###### ldf_version: str

Kind: Class Variable

###### classes: Dict[str, Dict[str, int]]

Kind: Class Variable

###### tasks: Dict[str, List[str]]

Kind: Class Variable

###### skeletons: Dict[str, Skeletons]

Kind: Class Variable

###### categorical_encodings: Dict[str, Dict[str, int]]

Kind: Class Variable

###### metadata_types: Dict[str, Literal['float', 'int', 'str', 'Category']]

Kind: Class Variable

###### parent_dataset: Optional[str]

Kind: Class Variable

###### set_classes(self, classes: Union [ List [ str ] , Dict [ str , int ] ], task: str)

Kind: Method

###### merge_with(self, other: Metadata) -> Metadata: Metadata

Kind: Method

Merge two metadata objects together.

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

Kind: Class

Abstraction for a piece of media within a source. Most commonly,

this abstracts an image sensor.

###### name

Kind: Instance Variable

A recognizable name for the component.

###### media_type

Kind: Instance Variable

Enum for the type of media for the component.

###### image_type

Kind: Instance Variable

Enum for the image type. Only used if media_type==MediaType.IMAGE.

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

Kind: Class

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.

###### name

Kind: Instance Variable

A recognizable name for the source. Defaults to "default".

###### components

Kind: Instance Variable

If not using the default configuration, a list of LuxonisComponent to group together in the source.

###### main_component

Kind: Instance Variable

The name of the component that should be primarily visualized.

###### merge_with(self, other: LuxonisSource) -> LuxonisSource: LuxonisSource

Kind: Method

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.

##### loaders

Kind: Package

###### base_loader

Kind: Module

###### luxonis_loader

Kind: Module

###### LOADERS_REGISTRY: Registry[Type[BaseLoader]]

Kind: Constant

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

Kind: Class

Base abstract loader class.

Enforces the LuxonisLoaderOutput output label structure.

###### __len__(self) -> int: int

Kind: Method

Returns the length of the dataset.

@rtype: int
@return: Length of the dataset.

###### __getitem__(self, idx: int) -> LoaderOutput: LoaderOutput

Kind: Method

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.

###### __iter__(self) -> Iterator[LoaderOutput]: Iterator[LoaderOutput]

Kind: Method

Iterates over the dataset.

@rtype: Iterator[L{LuxonisLoaderOutput}]
@return: Iterator over the dataset.

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

Kind: Class

###### __init__(self, dataset: LuxonisDataset, view: Union [ str , List [ str ] ] = 'train', augmentation_engine: Union [ Literal
[ ' albumentations ' ] , str ] = 'albumentations', augmentation_config: Optional [ Union [ List [ Params ] , PathType ] ] = None,
height: Optional [ int ] = None, width: Optional [ int ] = None, keep_aspect_ratio: bool = True, exclude_empty_annotations: bool =
False, color_space: Literal [ ' RGB ' , ' BGR ' ] = 'RGB', keep_categorical_as_strings: bool = False, update_mode: UpdateMode =
UpdateMode.ALWAYS)

Kind: Method

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: Literal["RGB", "BGR"]
@param color_space: The color space of the output images. Defaults
to C{"RGB"}.
@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:
- UpdateMode.ALWAYS: Force a fresh download
- UpdateMode.IF_EMPTY: Skip downloading if local data exists

###### exclude_empty_annotations

Kind: Instance Variable

###### color_space

Kind: Instance Variable

###### dataset

Kind: Instance Variable

###### sync_mode

Kind: Instance Variable

###### keep_categorical_as_strings

Kind: Instance Variable

###### view

Kind: Instance Variable

###### df

Kind: Instance Variable

###### classes

Kind: Instance Variable

###### augmentations

Kind: Instance Variable

###### instances

Kind: Instance Variable

###### idx_to_df_row

Kind: Instance Variable

###### tasks_without_background

Kind: Instance Variable

###### __len__(self) -> int: int

Kind: Method

Returns length of the dataset.

@rtype: int
@return: Length of the loader.

###### __getitem__(self, idx: int) -> LoaderOutput: LoaderOutput

Kind: Method

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.

##### parsers

Kind: Package

###### base_parser

Kind: Module

###### ParserOutput

Kind: Type Alias

Type alias for parser output.

Contains a function to create the annotation generator, list of classes
names, skeleton dictionary for keypoints and list of added images.

###### classification_directory_parser

Kind: Module

###### coco_parser

Kind: Module

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

Kind: Class

###### FIFTYONE: str

Kind: Constant

###### ROBOFLOW: str

Kind: Constant

###### clean_annotations(annotation_path: Path) -> Path: Path

Kind: Function

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").

###### create_ml_parser

Kind: Module

###### darknet_parser

Kind: Module

###### luxonis_parser

Kind: Module

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

Kind: Class

###### DIR: str

Kind: Constant

###### SPLIT: str

Kind: Constant

###### T

Kind: Type Variable

###### native_parser

Kind: Module

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

Kind: Class

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 BaseDataset.add method.

###### validate_split(split_path: Path) -> Optional[Dict[str, Any]]: Optional[Dict[str, Any]]

Kind: Static Method

###### validate(dataset_dir: Path) -> bool: bool

Kind: Static Method

###### from_dir(self, dataset_dir: Path) -> Tuple[List[Path], List[Path], List[Path]]: Tuple[List[Path], List[Path], List[Path]]

Kind: Method

###### from_split(self, annotation_path: Path) -> ParserOutput: ParserOutput

Kind: Method

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.

###### segmentation_mask_directory_parser

Kind: Module

###### solo_parser

Kind: Module

###### tensorflow_csv_parser

Kind: Module

###### voc_parser

Kind: Module

###### yolov4_parser

Kind: Module

###### yolov6_parser

Kind: Module

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

Kind: Class

###### dataset: BaseDataset

Kind: Class Variable

###### dataset_type: DatasetType

Kind: Class Variable

###### task_name: Optional[str]

Kind: Class Variable

###### validate_split(split_path: Path) -> Optional[Dict[str, Any]]: Optional[Dict[str, Any]]

Kind: Static Method

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.

###### validate(dataset_dir: Path) -> bool: bool

Kind: Static Method

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.

###### from_dir(self, dataset_dir: Path, kwargs) -> Tuple[List[str], List[str], List[str]]: Tuple[List[str], List[str], List[str]]

Kind: Method

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.

###### from_split(self, kwargs) -> ParserOutput: ParserOutput

Kind: Method

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.

###### parse_split(self, split: Optional [ str ] = None, random_split: bool = False, split_ratios: Optional [ Dict [ str , float ]
] = None, kwargs) -> BaseDataset: BaseDataset

Kind: Method

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.

###### parse_dir(self, dataset_dir: Path, kwargs) -> BaseDataset: BaseDataset

Kind: Method

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.

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

Kind: Class

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.

###### validate_split(split_path: Path) -> Optional[Dict[str, Any]]: Optional[Dict[str, Any]]

Kind: Static Method

###### validate(dataset_dir: Path) -> bool: bool

Kind: Static Method

###### from_dir(self, dataset_dir: Path) -> Tuple[List[Path], List[Path], List[Path]]: Tuple[List[Path], List[Path], List[Path]]

Kind: Method

###### from_split(self, class_dir: Path) -> ParserOutput: ParserOutput

Kind: Method

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.

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

Kind: Class

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/>}.

###### validate_split(split_path: Path) -> Optional[Dict[str, Any]]: Optional[Dict[str, Any]]

Kind: Static Method

###### validate(dataset_dir: Path) -> bool: bool

Kind: Static Method

###### from_dir(self, dataset_dir: Path, use_keypoint_ann: bool = False, keypoint_ann_paths: Optional [ Dict [ str , str ] ] =
None, split_val_to_test: bool = True) -> Tuple[List[Path], List[Path], List[Path]]: Tuple[List[Path], List[Path], List[Path]]

Kind: Method

###### from_split(self, image_dir: Path, annotation_path: Path) -> ParserOutput: ParserOutput

Kind: Method

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.

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

Kind: Class

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.

###### validate_split(split_path: Path) -> Optional[Dict[str, Any]]: Optional[Dict[str, Any]]

Kind: Static Method

###### validate(dataset_dir: Path) -> bool: bool

Kind: Static Method

###### from_dir(self, dataset_dir: Path) -> Tuple[List[Path], List[Path], List[Path]]: Tuple[List[Path], List[Path], List[Path]]

Kind: Method

###### from_split(self, image_dir: Path, annotation_path: Path) -> ParserOutput: ParserOutput

Kind: Method

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.

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

Kind: Class

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.

###### validate_split(split_path: Path) -> Optional[Dict[str, Any]]: Optional[Dict[str, Any]]

Kind: Static Method

###### validate(dataset_dir: Path) -> bool: bool

Kind: Static Method

###### from_dir(self, dataset_dir: Path) -> Tuple[List[Path], List[Path], List[Path]]: Tuple[List[Path], List[Path], List[Path]]

Kind: Method

###### from_split(self, image_dir: Path, classes_path: Path) -> ParserOutput: ParserOutput

Kind: Method

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.

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

Kind: Class

###### parsers: Dict[DatasetType, Type[BaseParser]]

Kind: Class Variable

###### __init__(self, dataset_dir: str, dataset_name: Optional [ str ] = None, save_dir: Optional [ Union [ Path , str ] ] = None,
dataset_plugin: T = None, dataset_type: Optional [ DatasetType ] = None, task_name: Optional [ str ] = None, kwargs)

Kind: Method

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[str]
@param task_name: Name of the task. If C{None}, the task name
is derived from the dataset format.
@type kwargs: Dict[str, Any]
@param kwargs: Additional C{kwargs} to be passed to the
constructor of specific L{BaseDataset} implementation.

###### dataset_dir

Kind: Instance Variable

###### dataset_type

Kind: Instance Variable

###### parser_type

Kind: Instance Variable

###### dataset_constructor

Kind: Instance Variable

###### dataset

Kind: Instance Variable

###### parser

Kind: Instance Variable

###### parse(self, kwargs) -> BaseDataset: BaseDataset

Kind: Method

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.

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

Kind: Class

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.

###### validate_split(split_path: Path) -> Optional[Dict[str, Any]]: Optional[Dict[str, Any]]

Kind: Static Method

###### validate(dataset_dir: Path) -> bool: bool

Kind: Static Method

###### from_dir(self, dataset_dir: Path) -> Tuple[List[Path], List[Path], List[Path]]: Tuple[List[Path], List[Path], List[Path]]

Kind: Method

###### from_split(self, image_dir: Path, seg_dir: Path, classes_path: Path) -> ParserOutput: ParserOutput

Kind: Method

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

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

Kind: Class

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.

###### validate_split(split_path: Path) -> Optional[Dict[str, Any]]: Optional[Dict[str, Any]]

Kind: Static Method

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.

###### validate(dataset_dir: Path) -> bool: bool

Kind: Static Method

Validates if the dataset is in an expected format.

@type dataset_dir: Path
@param dataset_dir: Path to source dataset directory.
@rtype: bool
@return: True if the dataset is in the expected format.

###### from_dir(self, dataset_dir: Path) -> Tuple[List[Path], List[Path], List[Path]]: Tuple[List[Path], List[Path], List[Path]]

Kind: Method

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.

###### from_split(self, split_path: Path) -> ParserOutput: ParserOutput

Kind: Method

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.

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

Kind: Class

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.

###### validate_split(split_path: Path) -> Optional[Dict[str, Any]]: Optional[Dict[str, Any]]

Kind: Static Method

###### validate(dataset_dir: Path) -> bool: bool

Kind: Static Method

###### from_dir(self, dataset_dir: Path) -> Tuple[List[Path], List[Path], List[Path]]: Tuple[List[Path], List[Path], List[Path]]

Kind: Method

###### from_split(self, image_dir: Path, annotation_path: Path) -> ParserOutput: ParserOutput

Kind: Method

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

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

Kind: Class

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.

###### validate_split(split_path: Path) -> Optional[Dict[str, Any]]: Optional[Dict[str, Any]]

Kind: Static Method

###### validate(dataset_dir: Path) -> bool: bool

Kind: Static Method

###### from_dir(self, dataset_dir: Path) -> Tuple[List[Path], List[Path], List[Path]]: Tuple[List[Path], List[Path], List[Path]]

Kind: Method

###### from_split(self, image_dir: Path, annotation_dir: Path) -> ParserOutput: ParserOutput

Kind: Method

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.

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

Kind: Class

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.

###### validate_split(split_path: Path) -> Optional[Dict[str, Any]]: Optional[Dict[str, Any]]

Kind: Static Method

###### validate(dataset_dir: Path) -> bool: bool

Kind: Static Method

###### from_dir(self, dataset_dir: Path) -> Tuple[List[Path], List[Path], List[Path]]: Tuple[List[Path], List[Path], List[Path]]

Kind: Method

###### from_split(self, image_dir: Path, annotation_path: Path, classes_path: Path) -> ParserOutput: ParserOutput

Kind: Method

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.

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

Kind: Class

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.

###### validate_split(split_path: Path) -> Optional[Dict[str, Any]]: Optional[Dict[str, Any]]

Kind: Static Method

###### validate(dataset_dir: Path) -> bool: bool

Kind: Static Method

###### from_dir(self, dataset_dir: Path) -> Tuple[List[Path], List[Path], List[Path]]: Tuple[List[Path], List[Path], List[Path]]

Kind: Method

###### from_split(self, image_dir: Path, annotation_dir: Path, classes_path: Path) -> ParserOutput: ParserOutput

Kind: Method

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.

##### utils

Kind: Package

###### constants

Kind: Module

###### LDF_VERSION: Version

Kind: Constant

The version of the Luxonis Data Format used by this library.

Mismatch in major version numbers indicates incompatibility. Minor
version numbers indicate new non-breaking features.

###### data_utils

Kind: Module

###### enums

Kind: Module

###### parquet

Kind: Module

###### task_utils

Kind: Module

###### visualizations

Kind: Module

###### luxonis_ml.data.utils.visualizations.ColorMap(typing.Mapping)

Kind: Class

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.

###### __init__(self)

Kind: Method

###### __getitem__(self, label: Hashable) -> RGB: RGB

Kind: Method

###### __iter__(self)

Kind: Method

###### __len__(self)

Kind: Method

###### distinct_color_generator(stop: int = -1) -> Generator[RGB, None, None]: Generator[RGB, None, None]

Kind: Function

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]

###### resolve_color(color: Color) -> RGB: RGB

Kind: Function

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.

###### rgb_to_hsv(color: Color) -> HSV: HSV

Kind: Function

Converts an RGB color to HSV.

@type color: Color
@param color: The color to convert.
@rtype: Tuple[float, float, float]
@return: The HSV tuple.

###### hsv_to_rgb(color: HSV) -> RGB: RGB

Kind: Function

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.

###### get_contrast_color(color: Color) -> RGB: RGB

Kind: Function

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.

###### str_to_rgb(string: str) -> RGB: RGB

Kind: Function

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.

###### draw_dashed_rectangle(image: np.ndarray, pt1: Tuple [ int , int ], pt2: Tuple [ int , int ], color: Color, thickness: int =
1, dash_length: int = 10)

Kind: Function

Draws a dashed rectangle on the image.

Adheres to OpenCV's rectangle drawing convention.

@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.

###### draw_cross(img: np.ndarray, center: Tuple [ int , int ], size: int = 5, color: Color = 0, thickness: int = 1)

Kind: Function

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.

###### 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

Kind: Function

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.

###### concat_images(image_dict: Dict [ str , np.ndarray ], padding: int = 10, label_height: int = 30) -> np.ndarray: np.ndarray

Kind: Function

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.

###### visualize(image: np.ndarray, labels: Labels, classes: Dict [ str , Dict [ str , int ] ], blend_all: bool = False) ->
np.ndarray: np.ndarray

Kind: Function

Visualizes the labels on the image.

@type image: np.ndarray
@param image: The image to visualize.
@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.

###### infer_task(old_task: str, class_name: Optional [ str ], current_classes: Dict [ str , Dict [ str , int ] ]) -> str: str

Kind: 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]]

Kind: Function

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.

###### warn_on_duplicates(df: pl.LazyFrame)

Kind: Function

###### luxonis_ml.data.utils.ParquetFileManager

Kind: Class

###### __init__(self, directory: PathType, num_rows: int = 100000)

Kind: Method

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.

###### dir

Kind: Instance Variable

###### parquet_files

Kind: Instance Variable

###### num_rows

Kind: Instance Variable

###### num

Kind: Instance Variable

###### current_file

Kind: Instance Variable

###### buffer

Kind: Instance Variable

###### row_count

Kind: Instance Variable

###### write(self, uuid: str, data: ParquetRecord)

Kind: Method

Writes a row to the current working parquet file.

@type data: Dict
@param data: A dictionary representing annotations, mapping
annotation types to values.

###### __enter__(self) -> ParquetFileManager: ParquetFileManager

Kind: Method

###### __exit__(self, _)

Kind: Method

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

Kind: Class

###### file: str

Kind: Class Variable

###### source_name: str

Kind: Class Variable

###### task_name: str

Kind: Class Variable

###### class_name: Optional[str]

Kind: Class Variable

###### instance_id: Optional[int]

Kind: Class Variable

###### task_type: Optional[str]

Kind: Class Variable

###### annotation: Optional[str]

Kind: Class Variable

###### get_task_name(task: str) -> str: str

Kind: Function

Returns the task name from a task.

@type task: str
@param task: The task.
@rtype: str
@return: The task name.

###### get_task_type(task: str) -> str: str

Kind: Function

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".

###### split_task(task: str) -> Tuple[str, str]: Tuple[str, str]

Kind: Function

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.

###### task_is_metadata(task: str) -> bool: bool

Kind: Function

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.

###### task_type_iterator(labels: Labels, task_type: TaskType) -> Iterator[Tuple[str, np.ndarray]]: Iterator[Tuple[str,
np.ndarray]]

Kind: Function

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.

##### luxonis_ml.data.BucketStorage(enum.Enum)

Kind: Class

Underlying object storage for a bucket.

###### LOCAL: str

Kind: Constant

###### S3: str

Kind: Constant

###### GCS: str

Kind: Constant

###### AZURE_BLOB: str

Kind: Constant

##### luxonis_ml.data.BucketType(enum.Enum)

Kind: Class

Whether bucket storage is internal to Luxonis or not.

###### INTERNAL: str

Kind: Constant

###### EXTERNAL: str

Kind: Constant

##### luxonis_ml.data.ImageType(enum.Enum)

Kind: Class

Image type for IMAGE HType.

###### COLOR: str

Kind: Constant

###### MONO: str

Kind: Constant

###### DISPARITY: str

Kind: Constant

##### luxonis_ml.data.MediaType(enum.Enum)

Kind: Class

Individual file type.

###### IMAGE: str

Kind: Constant

###### VIDEO: str

Kind: Constant

###### POINTCLOUD: str

Kind: Constant

##### load_dataset_plugins()

Kind: Function

Registers any external dataset BaseDataset class plugins.

##### load_loader_plugins()

Kind: Function

Registers any external dataset BaseLoader class plugins.

#### embeddings

Kind: Package

##### methods

Kind: Package

###### OOD

Kind: Module

Out-of-Distribution Detection for Embeddings.

This module provides two primary methods for detecting out-of-distribution (OOD) samples in embeddings. OOD samples can be crucial
to identify as they represent anomalies or novel patterns that don't conform to the expected distribution of the dataset.

Methods available:

Isolation Forests: A tree-based model that partitions the space in such a manner that anomalies are isolated from the rest.

Leverage with Linear Regression: Leverages (or hat values) represent the distance between the predicted values and the true
values. Higher leverages indicate potential OOD points.

Typical use cases include:

Anomaly Detection: Identifying rare patterns or outliers.

Dataset Reduction: By removing or studying OOD samples, we can have a more homogeneous dataset.

Expanding Datasets: Recognizing valuable data points that are distinct from the current distribution can be helpful when we're
looking to diversify the dataset, especially in iterative learning scenarios.

Dependencies:

numpy

scikit-learn

###### duplicate

Kind: Module

Near-duplicate Search with Qdrant and Weaviate.

Overview: This module provides utilities to detect and remove near-duplicate data points within a given set of embeddings. It
leverages vector databases (Qdrant or Weaviate) for efficient search and retrieval, and employs Kernel Density Estimation (KDE)
for optimal split based on embeddings' cosine similarity. This approach is particularly well-suited for handling high-dimensional
embeddings.

Key Features:

Vector Database Integration: Supports both Qdrant and Weaviate for flexible deployment options.

KDE-Based Near-Duplicate Detection: Uses KDE to identify clusters of near-duplicates, ensuring accuracy in high-dimensional
spaces.

Visualization: Allows plotting KDE results using matplotlib for intuitive understanding.

Dynamic KDE Peak Selection: Automatically determines the best candidates for removal based on KDE peaks, minimizing manual
thresholding.

Dependencies:

KDEpy

Qdrant (optional, for Qdrant-specific features)

Weaviate (optional, for Weaviate-specific features)

Functions:

search_vectordb(vectordb_api, query_vector, property_name, top_k): Searches for similar embeddings within the specified vector
database.

_plot_kde(xs, s, density, maxima, minima): Plots a KDE distribution.

kde_peaks(data, bandwidth="scott", plot=False): Identifies peaks in a KDE distribution.

find_similar(reference_embeddings, vectordb_api, k=100, n=1000, method="first", k_method=None, kde_bw="scott", plot=False): Finds
the most similar embeddings to the given reference embeddings.

Examples (using Qdrant):

Initialize a Qdrant client and retrieve embeddings: from luxonis_ml.embeddings.utils.qdrant import QdrantAPI qdrant_api =
QdrantAPI(host="localhost", port=6333) qdrant_api.create_collection("images", ["image_path", "embedding"]) id_X, X =
qdrant_api.get_all_embeddings()

Find similar embeddings using various methods: # By instance ID: ix, paths = find_similar_qdrant(id_X[i], qdrant_api,
"image_path", 5, 100, "first")

# Using KDE Peaks method: ix, paths = find_similar_qdrant(X[i], qdrant_api, "image_path", 5, 100, "first", "kde_peaks",
"silverman", plot=False)

# Based on average of multiple embeddings: dark_ix = np.array([10, 123, 333, 405]) emb_dark = X[dark_ix] remove_dark_ix, paths =
find_similar_qdrant(emb_dark, qdrant_api, "image_path", 25, 5000, "average", "kde_basic", "scott", plot=True)

Additional Notes:

For Weaviate-specific examples, refer to the provided code examples.

The search_vectordb function can be used with either Qdrant or Weaviate, depending on the provided vectordb_api object.

Adjust parameters like k, n, and kde_bw based on your dataset and requirements.

###### kde_peaks(data: np.ndarray, bandwidth: Union [ str , float ] = 'scott', plot: bool = False) -> Tuple[np.ndarray,
np.ndarray, int, float]: Tuple[np.ndarray, np.ndarray, int, float]

Kind: Function

Find peaks in a KDE distribution using scipy's argrelextrema
function.

@type data: np.ndarray
@param data: The data to fit the KDE.
@type bandwidth: Union[str, float]
@param bandwidth: The bandwidth to use for the KDE. Default is
'scott'.
@type plot: bool
@param plot: Whether to plot the KDE.
@rtype: Tuple[np.ndarray, np.ndarray, int, float]
@return: The indices of the KDE maxima, the indices of the KDE
minima, the index of the global maxima, and the standard
deviation of the data.

###### mistakes

Kind: Module

Mismatch Detection in Labelled Data.

This module provides functionalities to detect mismatches or potential mislabelling in a dataset based on various strategies. This
is crucial in supervised machine learning tasks where the quality of labels significantly affects model performance.

Methods implemented

Centroids: This method identifies mismatches by comparing the distance of data points to the centroid of their own class against
the distances to centroids of other classes.

KNN (k-Nearest Neighbors): This approach leverages the idea that if the majority of data is correctly labelled, then mislabelled
data will be corrected by its nearest neighbors.

[Note: DBSCAN was considered but not implemented due to underperformance.]

Usage

To use this module, import the desired methods and provide the embeddings and labels:

>>> from mismatch_detection import find_mismatches_centroids, find_mismatches_knn
>>> # Detect mismatches using centroids
>>> mismatches, new_labels = find_mismatches_centroids(X_train, y_train)
>>> # Detect mismatches using KNN
>>> mismatches, new_labels = find_mismatches_knn(X_train, y_train)

###### representative

Kind: Module

Find Representative Images from Embeddings.

This module offers techniques to identify representative images or embeddings within a dataset. This aids in achieving a condensed
yet expressive view of your data.

Methods

Greedy Search: Aims to find a diverse subset of images by maximizing the minimum similarity to any image outside the set.

K-Medoids: An adaptation of the k-means clustering algorithm, it partitions data into k clusters, each associated with a medoid.

Main Applications

Dataset Reduction: Helps in representing large datasets with a minimal subset while retaining the essence.

Validation Set Creation: Identifies diverse samples for a robust validation set.

Dependencies

numpy

scikit-learn

kmedoids

luxonis_ml

Example

Greedy Search:

# Assuming you have 'embeddings' as a numpy array of shape (num_images, embedding_dim) similarity_matrix =
calculate_similarity_matrix(embeddings) desired_size = int(len(embeddings) * 0.1) selected_image_indices =
find_representative_greedy(1-similarity_matrix, desired_size)

K-Medoids:

# to get all embeddings from qdrant: ids, embeddings = get_all_embeddings(qdrant_client, collection_name="mnist") # Assuming you
have 'embeddings' as a numpy array of shape (num_images, embedding_dim) similarity_matrix =
calculate_similarity_matrix(embeddings) desired_size = int(len(embeddings) * 0.1) selected_image_indices =
find_representative_kmedoids(similarity_matrix, desired_size)

###### find_representative_greedy_vectordb(vectordb_api: VectorDBAPI, desired_size: int = 1000, seed: int = None) -> List[int]:
List[int]

Kind: Function

Find the most representative embeddings using a greedy algorithm
with VectorDB.

@note: Due to many requests, this function is very slow. Use
vectordb_api.retrieve_all_embeddings() and
find_representative_greedy() instead.
@type vectordb_api: VectorDBAPI
@param vectordb_api: The Vector database client instance to use for
searches.
@type desired_size: int
@param desired_size: The desired size of the representative set.
Default is 1000.
@type seed: int
@param seed: The ID of the seed embedding. Default is None, which
means a random seed is chosen.
@rtype: List[int]
@return: The IDs of the representative embeddings.

###### find_similar(reference_embeddings: Union [ str , List [ str ] , List [ List [ float ] ] , np.ndarray ], vectordb_api:
VectorDBAPI, k: int = 100, n: int = 1000, method: str = 'first', k_method: Union [ str , None ] = None, kde_bw: Union [ str ,
float ] = 'scott', plot: bool = False) -> np.ndarray: np.ndarray

Kind: Function

Find the most similar embeddings to the reference embeddings.

@type reference_embeddings: Union[str, List[str], List[List[float]],
np.ndarray]
@param reference_embeddings: The embeddings to compare against. Or a
list of of embedding instance_ids that reside in VectorDB.
@type vectordb_api: VectorDBAPI
@param vectordb_api: The VectorDBAPI instance to use.
@type k: int
@param k: The number of embeddings to return. Default is 100.
@type n: int
@param n: The number of embeddings to compare against. Default is
1000. (This is the number of embeddings that are returned by the
VectorDB search. It matters for the KDE, as it can be slow for
large n. Your choice of n depends on the amount of duplicates in
your dataset, the more duplicates, the larger n should be. If
you have 2-10 duplicates per image, n=100 should be ok. If you
have 50-300 duplicates per image, n=1000 should work good
enough.
@type method: str
@param method: The method to use to find the most similar
embeddings. If 'first' use the first of the reference
embeddings. If 'average', use the average of the reference
embeddings.
@type k_method: str
@param k_method: The method to select the best k. If None, use k as
is. If 'kde_basic', use the minimum of the KDE. If 'kde_peaks',
use the minimum of the KDE peaks, according to a specific
hardcoded hevristics/thresholds.
@type kde_bw: Union[str, float]
@param kde_bw: The bandwidth to use for the KDE. Default is 'scott'.
@type plot: bool
@param plot: Whether to plot the KDE.
@rtype: np.array
@return: The instance_ids of the most similar embeddings.

###### find_mismatches_centroids(X: np.array, y: np.array) -> Tuple[np.array, np.array]: Tuple[np.array, np.array]

Kind: Function

Find mismatches in the dataset. A mismatch is defined as a sample
that is closer to another centroid than to its own centroid.

@type X: np.array
@param X: The embeddings to use.
@type y: np.array
@param y: The targets to use.
@rtype: Tuple[np.array, np.array]
@return: The indices of the mismatches and the new labels.

###### find_mismatches_knn(X: np.array, y: np.array, n_neighbors: int = 5) -> Tuple[np.array, np.array]: Tuple[np.array, np.array]

Kind: Function

Find mismatches in the dataset.
Single Algorithm Filter (see Figure 1 in Brodley, Carla E., and Mark A. Friedl. "Identifying mislabeled training data.").
Idea: if the vast majority of the data is correctly labeled and you do knn prediction, the minority of mislabeled data will be
engulfed (corrected) by the correct neighbors.

@type X: np.array
@param X: The embeddings to use.

@type y: np.array
@param y: The targets to use.

@type n_neighbors: int
@param n_neighbors: The number of neighbors to use for KNN. Default is 5.

@rtype: Tuple[np.array, np.array]
@return: The indices of the mismatches and the new labels.

###### isolation_forest_OOD(X: np.array, contamination: Union [ float , str ] = 'auto', n_jobs: int = -1, verbose: int = 1,
random_state: Optional [ int ] = None) -> np.array: np.array

Kind: Function

Out-of-distribution detection using Isolation Forests.

@type X: np.array
@param X: The embeddings to use.
@type contamination: Union[float, str]
@param contamination: The contamination parameter for Isolation
Forests. Default is 'auto'.
@type n_jobs: int
@param n_jobs: The number of jobs to use. Default is -1, which means
all available CPUs.
@type verbose: int
@param verbose: The verbosity level. Default is 1.
@type random_state: Optional[int]
@param random_state: The random state to use. Default is None.
@rtype: np.array
@return: The indices of the embeddings that are in-distribution.

###### leverage_OOD(X: np.array, std_threshold: int = 3) -> np.array: np.array

Kind: Function

Out-of-distribution detection using leverage and linear
regression.

@type X: np.array
@param X: The embeddings to use.
@type std_threshold: int
@param std_threshold: The number of standard deviations to use for
the leverage threshold. Default is 3.
@rtype: np.array
@return: The indices of the embeddings that are out-of-distribution.

###### calculate_similarity_matrix(embeddings: np.ndarray) -> np.ndarray: np.ndarray

Kind: Function

###### find_representative_greedy(distance_matrix: np.ndarray, desired_size: int = 1000, seed: int = 0) -> List[int]: List[int]

Kind: Function

Find the most representative images using a greedy algorithm.
Gready search of maximally unique embeddings.

@type distance_matrix: np.array
@param distance_matrix: The distance matrix to use.
@type desired_size: int
@param desired_size: The desired size of the representative set.
Default is 1000.
@type seed: int
@param seed: The index of the seed image. Default is 0. Must be in
the range [0, num_images-1].
@rtype: List[int]
@return: The indices of the representative images.

###### find_representative_kmedoids(similarity_matrix: np.ndarray, desired_size: int = 1000, max_iter: int = 100, seed: int =
None) -> List[int]: List[int]

Kind: Function

Find the most representative images using k-medoids. K-medoids
clustering of embeddings.

@type similarity_matrix: np.array
@param similarity_matrix: The similarity matrix to use.
@type desired_size: int
@param desired_size: The desired size of the representative set.
Default is 1000.
@type max_iter: int
@param max_iter: The maximum number of iterations to use. Default is
100.
@type seed: int
@param seed: The random seed to use. Default is None.
@rtype: list
@return: The indices of the representative images.

##### utils

Kind: Package

###### embedding

Kind: Module

Embeddings Extractor and Storage for ONNX Models.

This module provides utility functions specifically for extracting embeddings from ONNX models, reading images from Luxonis
Filesystem (LFS), and storing/retrieving embeddings to/from disk.

Key Functions:

extract_embeddings(image_paths, ort_session, lfs, ...) Extracts embeddings from an ONNX model, reading images from LFS and
handling potential errors.

get_image_tensors_from_LFS(image_paths, preprocess_function, lfs) Reads images from LFS, applies preprocessing, and returns a list
of tensors.

preprocess_image_cv2(img) Example preprocessing function for resizing, normalization, and channel arrangement.

Workflow:

Load the ONNX model into an ONNX Runtime session.

Provide a list of image paths (stored on LFS) to the extract_embeddings function.

Optionally, specify a custom preprocessing function for image preparation.

The function extracts embeddings in batches, handles errors, and returns the extracted embeddings.

Additional Features:

Saving and loading embeddings to/from disk (functions not yet implemented in this version).

Dependencies:

onnxruntime

cv2

numpy

Note:

Ensure the output_layer_name in extract_embeddings matches the appropriate output layer in the ONNX model.

This module specifically focuses on ONNX models and reading images from Luxonis Filesystem.

###### preprocess_image_cv2(img: np.ndarray) -> np.ndarray: np.ndarray

Kind: Function

Custom preprocessing function provided by the user.

###### get_image_tensors_from_remote(image_paths: List [ str ], preprocess_function: Callable [ [ np.ndarray ] , np.ndarray ],
lfs: LuxonisFileSystem) -> Tuple[np.ndarray, List[int]]: Tuple[np.ndarray, List[int]]

Kind: Function

###### ldf

Kind: Module

Utilities for generating image embeddings and inserting them into a VectorDB database.

This script provides functions for:

Extracting payloads from LuxonisDatasets, specifically for classification datasets.

Filtering new samples based on their instance IDs to avoid duplicates in the database.

Generating embeddings for new images using an ONNX runtime session.

Performing batch upserts of embeddings into a VectorDB database.

Key modules used:

luxonis_ml.data: For loading and working with LuxonisDatasets.

luxonis_ml.embeddings.utils.embedding: For extracting embeddings from images.

luxonis_ml.embeddings.utils.vectordb: For interacting with VectorDB databases.

Main functions:

_get_sample_payloads_LDF: Extracts payloads from a LuxonisDataset for classification datasets.

_filter_new_samples_by_id: Filters out samples already in the database based on instance IDs.

_batch_upsert: Performs batch upserts of embeddings into the database.

generate_embeddings: Main function to generate embeddings for a dataset and insert them into the database.

Important note:

Ensure that a VectorDB server is running and accessible before using these utilities.

###### model

Kind: Module

Model Utility Functions.

This script provides utility functions for handling ONNX models. It allows manipulating ONNX models in order to extract
intermediate outputs aka embeddings.

Functions:

load_model_onnx(model_path: str = "resnet50.onnx") -> onnx.ModelProto: Loads an ONNX model from the specified file path.

save_model_onnx(model: onnx.ModelProto, model_path_out: str = "resnet50.onnx"): Saves an ONNX model to the specified file path.

extend_output_onnx(onnx_model: onnx.ModelProto, intermediate_tensor_name: str = "/Flatten_output_0") -> onnx.ModelProto: Sets an
intermediate output layer as output of the provided ONNX model. If overwrite is set to True, the second to last layer output will
be set as output layer and renamed.

Dependencies:

onnx

###### qdrant

Kind: Module

Qdrant Docker Management and Embedding Operations.

This script provides utility functions for managing Qdrant via Docker and performing operations related to embeddings.

Features include:

Docker management: Checks for Docker installation, running status, and existence of specific images or containers.

Qdrant management: Facilitates starting a Qdrant container, connecting to Qdrant, and creating collections.

Embedding operations: Supports inserting, batch inserting, searching, and retrieving embeddings within a Qdrant collection.

Dependencies:

os: Standard library module for interacting with the operating system.

docker: Library to manage Docker containers.

qdrant_client: Client library for interacting with the Qdrant service.

Usage steps:

Ensure Docker is installed and running on your system.

Utilize the QdrantManager class and its start_docker_qdrant() method to initiate a Qdrant container.

Employ the QdrantAPI class to either connect to an existing Qdrant service or create a new collection.

Use the QdrantAPI class to perform various embedding-related operations within the specified Qdrant collection.

Note:

The default collection name is 'mnist'.

It is essential that the user has appropriate permissions to execute Docker commands without sudo.

For guidance on setting this up, refer to: https://docs.docker.com/engine/install/linux-postinstall/

###### vectordb

Kind: Module

###### weaviate

Kind: Module

###### extract_embeddings(image_paths: List [ str ], ort_session: ort.InferenceSession, lfs: LuxonisFileSystem,
preprocess_function: Callable [ [ np.ndarray ] , np.ndarray ], output_layer_name: str = '/Flatten_output_0', batch_size: int = 64)
-> Tuple[List[List[float]], List[int]]: Tuple[List[List[float]], List[int]]

Kind: Function

###### generate_embeddings(luxonis_dataset: LuxonisDataset, ort_session: onnxruntime.InferenceSession, vectordb_api: VectorDBAPI,
output_layer_name: str = '/Flatten_output_0', transform: Callable [ [ np.ndarray ] , np.ndarray ] = None, emb_batch_size: int =
64, vectordb_batch_size: int = 64) -> Dict[str, List[float]]: Dict[str, List[float]]

Kind: Function

Generate embeddings for a given dataset and insert them into a
VectorDB.

@type luxonis_dataset: L{LuxonisDataset}
@param luxonis_dataset: The dataset object.
@type ort_session: L{InferenceSession}
@param ort_session: ONNX runtime session.
@type vectordb_api: L{VectorDBAPI}
@param vectordb_api: VectorDBAPI instance.
@type output_layer_name: str
@param output_layer_name: Name of the output layer in the ONNX
model.
@type transform: Callable[[np.ndarray], np.ndarray]
@param transform: Preprocessing function for images. If None,
default preprocessing is used.
@type emb_batch_size: int
@param emb_batch_size: Batch size for generating embeddings.
@type vectordb_batch_size: int
@param vectordb_batch_size: Batch size for inserting into a vector
DB.
@type: Dict[str, List[float]]
@return: Dictionary of instance ID to embedding.

###### extend_output_onnx(onnx_model: onnx.ModelProto, intermediate_tensor_name: str = '/Flatten_output_0', overwrite: bool =
False) -> onnx.ModelProto: onnx.ModelProto

Kind: Function

Set an intermediate output layer as output of the provided ONNX
model.

If C{overwrite} is set to True, the second to last layer output will
be set as output layer and renamed.

(You need to know the name of the intermediate layer, which you can
find by inspecting the ONNX model with Netron.app)

###### load_model_onnx(model_path: str = 'resnet50.onnx') -> onnx.ModelProto: onnx.ModelProto

Kind: Function

Load an ONNX model from the provided path.

###### save_model_onnx(model: onnx.ModelProto, model_path_out: str = 'resnet50.onnx')

Kind: Function

Save an ONNX model to the specified file path.

###### luxonis_ml.embeddings.utils.QdrantAPI(luxonis_ml.embeddings.utils.VectorDBAPI)

Kind: Class

Class to perform various Qdrant operations related to embeddings.

###### __init__(self, host: str = 'localhost', port: int = 6333)

Kind: Method

Initialize the QdrantAPI without setting a specific
collection.

@type host: str
@param host: The host address of the Qdrant server. Default is
"localhost".
@type port: int
@param port: The port number of the Qdrant server. Default is
6333.

###### client

Kind: Instance Variable

###### create_collection(self, collection_name: str, properties: List [ str ], vector_size: int = 512)

Kind: Method

Create a collection in Qdrant with specified properties.

@type collection_name: str
@param collection_name: The name of the collection.
@type properties: List[str]
@param properties: The list of properties for the collection.
@type vector_size: int
@param vector_size: The size of the embedding vectors. Default
is 512.

###### collection_name

Kind: Instance Variable

###### properties

Kind: Instance Variable

###### delete_collection(self)

Kind: Method

Delete a collection in Qdrant.

###### insert_embeddings(self, ids: List [ str ], embeddings: List [ List [ float ] ], payloads: List [ Dict [ str , Any ] ],
batch_size: int = 50)

Kind: Method

Batch insert embeddings with IDs and additional metadata into
a collection.

@type ids: List[str]
@param ids: The list of instance_ids for the embeddings.
@type embeddings: List[List[float]]
@param embeddings: The list of embedding vectors.
@type payloads: List[Dict[str, Any]]
@param payloads: The list of additional metadata for the
embeddings.
@type batch_size: int
@param batch_size: The batch size for inserting embeddings.
Default is 50.

###### search_similar_embeddings(self, embedding: List [ float ], top_k: int = 5) -> Tuple[List[str], List[float]]:
Tuple[List[str], List[float]]

Kind: Method

Search for the top similar embeddings in a Qdrant collection.

@type embedding: List[float]
@param embedding: The query embedding vector.
@type top_k: int
@param top_k: The number of similar embeddings to retrieve.
Default is 5.
@rtype: Tuple[List[str], List[float]]
@return: The list of instance_ids of the similar embeddings and
the list of similarity scores.

###### get_similarity_scores(self, reference_id: str, other_ids: List [ str ], sort_distances: bool = True) -> Tuple[List[str],
List[float]]: Tuple[List[str], List[float]]

Kind: Method

Get a list of similarity scores between the reference
embedding and other embeddings.

@type reference_id: int
@param reference_id: The instance_id of the reference embedding.
@type other_ids: List[int]
@param other_ids: The list of instance_ids of other embeddings
to compare with the reference.
@type sort_distances: bool
@param sort_distances: Whether to sort the results by distance
or keep the original order.
@rtype: Tuple[List[int], List[float]
@return: The list of instance_ids of the other embeddings and
the list of similarity scores.

###### compute_similarity_matrix(self) -> List[List[float]]: List[List[float]]

Kind: Method

Compute a full similarity matrix for all embeddings in a
Qdrant collection.

@rtype: Tuple[List[str], List[List[float]]]
@return: The list of instance_ids of the embeddings and the
similarity matrix.
@note: This method is not recommended for large collections. It
is better to use the L{get_all_embeddings} method and
compute the similarity matrix yourself.

###### retrieve_embeddings_by_ids(self, ids: List [ str ]) -> List[List[float]]: List[List[float]]

Kind: Method

Retrieve embeddings associated with a list of IDs from a
Qdrant collection. The order of the embeddings IS preserved.

@type ids: List[str]
@param ids: The list of instance_ids of the embeddings to
retrieve.
@rtype: List[List[float]]
@return: The list of embedding vectors.

###### retrieve_all_ids(self) -> List[str]: List[str]

Kind: Method

Retrieve all IDs from a Qdrant collection.

@rtype: List[str]
@return: The list of instance_ids of the embeddings.

###### retrieve_all_embeddings(self) -> Tuple[List[str], List[List[float]]]: Tuple[List[str], List[List[float]]]

Kind: Method

Retrieve all embeddings and their IDs from a Qdrant
collection.

@rtype: Tuple[List[str], List[List[float]]]
@return: The list of instance_ids of the embeddings and the list
of embedding vectors.

###### retrieve_payloads_by_ids(self, ids: List [ str ], properties: Optional [ List [ str ] ] = None) -> List[Dict[str, Any]]:
List[Dict[str, Any]]

Kind: Method

Retrieve specified payload properties for a list of IDs from
a collection. The order of the labels IS preserved.

@type ids: List[str]
@param ids: The list of instance_ids of the embeddings to
retrieve.
@type properties: Optional[List[str]]
@param properties: The list of payload properties to retrieve.
Default is None.
@rtype: List[Dict[str, Any]]
@return: The list of payload dictionaries.

###### luxonis_ml.embeddings.utils.QdrantManager

Kind: Class

Class to manage Qdrant Docker container and perform various operations related to embeddings.

###### __init__(self, image_name = 'qdrant/qdrant', container_name = 'qdrant_container')

Kind: Method

Initialize the QdrantManager.

###### image_name

Kind: Instance Variable

###### container_name

Kind: Instance Variable

###### client_docker

Kind: Instance Variable

###### is_docker_installed(self)

Kind: Method

Check if Docker is installed.

###### is_docker_running(self)

Kind: Method

Check if Docker daemon is running.

###### does_image_exist(self)

Kind: Method

Check if a Docker image exists.

###### does_container_exist(self)

Kind: Method

Check if a Docker container exists.

###### is_container_running(self)

Kind: Method

Check if a Docker container is running.

###### start_docker_qdrant(self)

Kind: Method

Start the Qdrant Docker container.

@note: Make sure the user has the appropriate permissions to run Docker commands
without sudo. Otherwise, the client_docker.images.pull() command will fail.
See U{https://docs.docker.com/engine/install/linux-postinstall/} for more details.

###### stop_docker_qdrant(self)

Kind: Method

Stop the Qdrant Docker container.

###### luxonis_ml.embeddings.utils.VectorDBAPI(abc.ABC)

Kind: Class

Abstract class for Vector Database APIs.

This class defines a common interface for vector database operations for different implementations like Qdrant and Weaviate.

###### create_collection(self, collection_name: str, properties: List [ str ])

Kind: Method

Create a collection in the vector database.

###### delete_collection(self)

Kind: Method

Delete the collection from the vector database.

###### insert_embeddings(self, ids: List [ str ], embeddings: List [ List [ float ] ], payloads: List [ Dict [ str , Any ] ],
batch_size: int = 100)

Kind: Method

Insert embeddings into the collection.

###### search_similar_embeddings(self, embedding: List [ float ], top_k: int = 10) -> Tuple[List[str], List[float]]:
Tuple[List[str], List[float]]

Kind: Method

Search for similar embeddings in the collection.

###### get_similarity_scores(self, reference_id: str, other_ids: List [ str ], sort_distances: bool = True) -> Tuple[List[str],
List[float]]: Tuple[List[str], List[float]]

Kind: Method

Get similarity scores between a reference embedding and other
embeddings.

###### compute_similarity_matrix(self) -> List[List[float]]: List[List[float]]

Kind: Method

Compute a similarity matrix for all the embeddings in the
collection.

###### retrieve_embeddings_by_ids(self, ids: List [ str ]) -> List[List[float]]: List[List[float]]

Kind: Method

Retrieve embeddings associated with a list of IDs.

###### retrieve_all_embeddings(self) -> Tuple[List[str], List[List[float]]]: Tuple[List[str], List[List[float]]]

Kind: Method

Retrieve all embeddings from the collection.

###### retrieve_all_ids(self) -> List[str]: List[str]

Kind: Method

Retrieve all IDs from the collection.

###### retrieve_payloads_by_ids(self, ids: List [ str ], properties: Optional [ List [ str ] ]) -> List[Dict[str, Any]]:
List[Dict[str, Any]]

Kind: Method

Retrieve payloads associated with a list of IDs.

###### luxonis_ml.embeddings.utils.WeaviateAPI(luxonis_ml.embeddings.utils.VectorDBAPI)

Kind: Class

Provides a Python interface for interacting with Weaviate, facilitating operations such as creating collections, managing
embeddings, and querying for similar embeddings.

It only supports cosine similarity for now.

###### __init__(self, url: str = 'http://localhost:8080', grpc_url: str = 'http://localhost:50051', auth_api_key: str = None)

Kind: Method

Initializes the Weaviate API client with connection details.

@type url: str
@param url: URL of the Weaviate instance, defaults to
U{localhost:8080}.
@type grpc_url: str
@param grpc_url: URL of the gRPC Weaviate instance, defaults to
U{localhost:50051}.
@type auth_api_key: str
@param auth_api_key: API key for authentication. Defaults to
C{None}.

###### client

Kind: Instance Variable

###### create_collection(self, collection_name: str, properties: List [ str ] = None)

Kind: Method

Creates a new collection in the Weaviate database.

@type collection_name: str
@param collection_name: Name of the collection to create.
@type properties: List[str]
@param properties: List of properties for the collection.
Defaults to None.

###### collection_name

Kind: Instance Variable

###### properties

Kind: Instance Variable

###### collection

Kind: Instance Variable

###### delete_collection(self)

Kind: Method

Deletes a collection from the Weaviate database.

###### insert_embeddings(self, uuids: List [ str ], embeddings: List [ List [ float ] ], payloads: List [ Dict [ str , Any ] ],
batch_size: int = 100)

Kind: Method

Inserts embeddings with associated payloads into a
collection.

@type uuids: List[str]
@param uuids: List of UUIDs for the embeddings.
@type embeddings: List[List[float]]
@param embeddings: List of embeddings.
@type payloads: List[Dict[str, Any]]
@param payloads: List of payloads.
@type batch_size: int
@param batch_size: Batch size for inserting the embeddings.

###### search_similar_embeddings(self, embedding: List [ float ], top_k: int = 10) -> Tuple[List[str], List[float]]:
Tuple[List[str], List[float]]

Kind: Method

Searches for embeddings similar to a given vector.

@type embedding: List[float]
@param embedding: Embedding to find similar embeddings for.
@type top_k: int
@param top_k: Number of similar embeddings to find.
@rtype uuids: List[str]
@return uuids: List of UUIDs of the similar embeddings.
@rtype scores: List[float]
@return scores: List of similarity scores.

###### get_similarity_scores(self, reference_id: str, other_ids: List [ str ], sort_distances: bool = False) -> Tuple[List[str],
List[float]]: Tuple[List[str], List[float]]

Kind: Method

Calculates the similarity score between the reference
embedding and the specified embeddings.

@type reference_id: str
@param reference_id: UUID of the reference embedding.
@type other_ids: List[str]
@param other_ids: List of UUIDs of the embeddings to compare to.
@type sort_distances: bool
@param sort_distances: Whether to sort the results by distance
or keep order of the UUIDs. Defaults to False.
@rtype ids: List[str]
@return ids: List of UUIDs of the embeddings.
@rtype scores: List[float]
@return scores: List of similarity scores.

###### compute_similarity_matrix(self) -> List[List[float]]: List[List[float]]

Kind: Method

Calculates the similarity matrix for all the embeddings in
the collection. @note: This is a very inefficient
implementation. For large numbers of embeddings, calculate the
similarity matrix by hand
(sklearn.metrics.pairwise.cosine_similarity).

@rtype sim_matrix: List[List[float]]
@return sim_matrix: Similarity matrix for all the embeddings in
the collection.

###### retrieve_embeddings_by_ids(self, uuids: List [ str ]) -> List[List[float]]: List[List[float]]

Kind: Method

Gets the embeddings for the specified UUIDs, up to a maximum
of 10000.

@type uuids: List[str]
@param uuids: List of UUIDs of the embeddings to get.
@rtype embeddings: List[List[float]]
@return embeddings: List of embeddings.

###### retrieve_payloads_by_ids(self, uuids: List [ str ], properties: Optional [ List [ str ] ] = None) -> List[Dict[str, Any]]:
List[Dict[str, Any]]

Kind: Method

Gets the payloads for the specified UUIDs, up to a maximum of
10000.

@type uuids: List[str]
@param uuids: List of UUIDs of the embeddings to get.
@type properties: List[str]
@param properties: List of properties to retrieve.
@rtype payloads: List[Dict[str, Any]]
@return payloads: List of payloads.

###### retrieve_all_ids(self) -> List[str]: List[str]

Kind: Method

Gets all the UUIDs in the Weaviate collection.

@rtype uuids: List[str]
@return uuids: List of UUIDs.

###### retrieve_all_embeddings(self) -> Tuple[List[str], List[List[float]]]: Tuple[List[str], List[List[float]]]

Kind: Method

Gets all the embeddings and UUIDs in the Weaviate collection.

@rtype uuids: List[str]
@return uuids: List of UUIDs.
@rtype embeddings: List[List[float]]
@return embeddings: List of embeddings.

#### enums

Kind: Package

##### enums

Kind: Module

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

Kind: Class

###### LDF: str

Kind: Constant

###### COCO: str

Kind: Constant

###### VOC: str

Kind: Constant

###### DARKNET: str

Kind: Constant

###### YOLOV6: str

Kind: Constant

###### YOLOV4: str

Kind: Constant

###### CREATEML: str

Kind: Constant

###### TFCSV: str

Kind: Constant

###### CLSDIR: str

Kind: Constant

###### SEGMASK: str

Kind: Constant

###### SOLO: str

Kind: Constant

###### NATIVE: str

Kind: Constant

#### guard_extras

Kind: Module

##### guard_missing_extra(name: str)

Kind: Function

#### nn_archive

Kind: Package

##### archive_generator

Kind: Module

##### config

Kind: Module

###### CONFIG_VERSION: str

Kind: Constant

##### config_building_blocks

Kind: Package

###### base_models

Kind: Package

###### head

Kind: Module

###### head_metadata

Kind: Module

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

Kind: Class

Metadata for the object detection head.

###### classes

Kind: Instance Variable

Names of object classes detected by the model.

###### n_classes

Kind: Instance Variable

Number of object classes detected by the model.

###### iou_threshold

Kind: Instance Variable

Non-max supression threshold limiting boxes intersection.

###### conf_threshold

Kind: Instance Variable

Confidence score threshold above which a detected object is considered valid.

###### max_det

Kind: Instance Variable

Maximum detections per image.

###### anchors

Kind: Instance Variable

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.

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

Kind: Class

Metadata for the SSD object detection head.

###### boxes_outputs

Kind: Instance Variable

Output name corresponding to predicted bounding box coordinates.

###### scores_outputs

Kind: Instance Variable

Output name corresponding to predicted bounding box confidence scores.

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

Kind: Class

Metadata for the classification head.

###### classes

Kind: Instance Variable

Names of object classes classified by the model.

###### n_classes

Kind: Instance Variable

Number of object classes classified by the model.

###### is_softmax

Kind: Instance Variable

True, if output is already softmaxed

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

Kind: Class

Metadata for the segmentation head.

###### classes

Kind: Instance Variable

Names of object classes segmented by the model.

###### n_classes

Kind: Instance Variable

Number of object classes segmented by the model.

###### is_softmax

Kind: Instance Variable

True, if output is already softmaxed

######
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)

Kind: Class

Metadata for the YOLO head.

###### yolo_outputs

Kind: Instance Variable

A list of output names for each of the different YOLO grid sizes.

###### mask_outputs

Kind: Instance Variable

A list of output names for each mask output.

###### protos_outputs

Kind: Instance Variable

Output name for the protos.

###### keypoints_outputs

Kind: Instance Variable

A list of output names for the keypoints.

###### angles_outputs

Kind: Instance Variable

A list of output names for the angles.

###### subtype

Kind: Instance Variable

YOLO family decoding subtype (e.g. yolov5, yolov6, yolov7 etc.)

###### n_prototypes

Kind: Instance Variable

Number of prototypes per bbox in YOLO instance segmnetation.

###### n_keypoints

Kind: Instance Variable

Number of keypoints per bbox in YOLO keypoint detection.

###### is_softmax

Kind: Instance Variable

True, if output is already softmaxed in YOLO instance segmentation

###### validate_task_specific_fields(cls, values)

Kind: Method

###### input

Kind: Module

###### metadata

Kind: Module

###### output

Kind: Module

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

Kind: Class

Represents head of a model.

###### name

Kind: Instance Variable

Optional name of the head.

###### parser

Kind: Instance Variable

Name of the parser responsible for processing the models output.

###### outputs

Kind: Instance Variable

Specify which outputs are fed into the parser. If None, all outputs are fed.

###### metadata

Kind: Instance Variable

Metadata of the parser.

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

Kind: Class

Metadata for the basic head. It allows you to specify additional fields.

###### postprocessor_path

Kind: Instance Variable

Path to the postprocessor.

###### model_config

Kind: Class Variable

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

Kind: Class

Represents input stream of a model.

###### name

Kind: Instance Variable

Name of the input layer.

###### dtype

Kind: Instance Variable

Data type of the input data (e.g., 'float32').

###### input_type

Kind: Instance Variable

Type of input data (e.g., 'image').

###### shape

Kind: Instance Variable

Shape of the input data as a list of integers (e.g. [H,W], [H,W,C], [N,H,W,C], ...).

###### layout

Kind: Instance Variable

Lettercode interpretation of the input data dimensions (e.g., 'NCHW').

###### preprocessing

Kind: Instance Variable

Preprocessing steps applied to the input data.

###### validate_layout(self) -> Self: Self

Kind: Method

###### infer_layout(data: Dict [ str , Any ]) -> Dict[str, Any]: Dict[str, Any]

Kind: Static Method

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

Kind: Class

Represents preprocessing operations applied to the input data.

###### mean

Kind: Instance Variable

Mean values in channel order. Order depends on the order in which the model was trained on.

###### scale

Kind: Instance Variable

Standardization values in channel order. Order depends on the order in which the model was trained on.

###### reverse_channels

Kind: Instance Variable

If True input to the model is RGB else BGR.

###### interleaved_to_planar

Kind: Instance Variable

If True input to the model is interleaved (NHWC) else planar (NCHW).

###### dai_type

Kind: Instance Variable

DepthAI input type which is read by DepthAI to automatically setup the pipeline.

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

Kind: Class

Represents metadata of a model.

###### name

Kind: Instance Variable

Name of the model.

###### path

Kind: Instance Variable

Relative path to the model executable.

###### precision: DataType

Kind: Class Variable

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

Kind: Class

Represents output stream of a model.

###### name

Kind: Instance Variable

Name of the output layer.

###### dtype

Kind: Instance Variable

Data type of the output data (e.g., 'float32').

###### shape: Optional[List[int]]

Kind: Class Variable

###### layout

Kind: Instance Variable

###### validate_layout(self) -> Self: Self

Kind: Method

###### infer_layout(self) -> Self: Self

Kind: Method

###### enums

Kind: Package

###### data_type

Kind: Module

###### input_type

Kind: Module

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

Kind: Class

Represents all existing data types used in i/o streams of the model.

###### INT4: str

Kind: Constant

###### INT8: str

Kind: Constant

###### INT16: str

Kind: Constant

###### INT32: str

Kind: Constant

###### INT64: str

Kind: Constant

###### UINT4: str

Kind: Constant

###### UINT8: str

Kind: Constant

###### UINT16: str

Kind: Constant

###### UINT32: str

Kind: Constant

###### UINT64: str

Kind: Constant

###### FLOAT16: str

Kind: Constant

###### FLOAT32: str

Kind: Constant

###### FLOAT64: str

Kind: Constant

###### BOOLEAN: str

Kind: Constant

###### STRING: str

Kind: Constant

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

Kind: Class

Represents a type of input the model is expecting.

###### RAW: str

Kind: Constant

###### IMAGE: str

Kind: Constant

##### model

Kind: Module

##### utils

Kind: Module

##### luxonis_ml.nn_archive.ArchiveGenerator

Kind: Class

Generator of abstracted NN archive (.tar) files containing config and model files (executables).

###### archive_name

Kind: Instance Variable

Desired archive file name.

###### save_path

Kind: Instance Variable

Path to where we want to save the archive file.

###### cfg_dict

Kind: Instance Variable

Archive configuration dict.

###### executables_paths

Kind: Instance Variable

Paths to relevant model executables.

###### compression

Kind: Instance Variable

Type of archive file compression ("xz" for LZMA, "gz" for gzip, or "bz2" for bzip2 compression).

###### __init__(self, archive_name: str, save_path: str, cfg_dict: dict, executables_paths: List [ str ], compression: Literal [ '
xz ' , ' gz ' , ' bz2 ' ] = 'xz')

Kind: Method

###### cfg

Kind: Instance Variable

###### make_archive(self) -> str: str

Kind: Method

Run NN archive (.tar) file generation.

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

Kind: Class

The main class of the multi/single-stage model config scheme (multi- stage models consists of interconnected single-stage models).

###### config_version

Kind: Instance Variable

String representing config schema version in format 'x.y' where x is major version and y is minor version

###### model

Kind: Instance Variable

A Model object representing the neural network used in the archive.

###### validate_config_version_format(cls, v)

Kind: Method

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

Kind: Class

Class defining a single-stage model config scheme.

###### metadata

Kind: Instance Variable

Metadata object defining the model metadata.

###### inputs

Kind: Instance Variable

List of Input objects defining the model inputs.

###### outputs

Kind: Instance Variable

List of Output objects defining the model outputs.

###### heads

Kind: Instance Variable

List of Head objects defining the model heads. If not defined, we assume a raw output.

##### infer_layout(shape: List [ int ]) -> str: str

Kind: Function

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"

##### is_nn_archive(path: PathType) -> bool: bool

Kind: Function

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.

#### tracker

Kind: Package

##### mlflow_plugins

Kind: Module

##### tracker

Kind: Module

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

Kind: Class

###### in_context(self)

Kind: Method

###### request_headers(self)

Kind: Method

##### luxonis_ml.tracker.LuxonisTracker

Kind: Class

###### __init__(self, project_name: Optional [ str ] = None, project_id: Optional [ str ] = None, run_name: Optional [ str ] =
None, run_id: Optional [ str ] = None, save_directory: str = 'output', is_tensorboard: bool = False, is_wandb: bool = False,
is_mlflow: bool = False, is_sweep: bool = False, wandb_entity: Optional [ str ] = None, mlflow_tracking_uri: Optional [ str ] =
None, rank: int = 0)

Kind: Method

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.

###### project_name

Kind: Instance Variable

###### project_id

Kind: Instance Variable

###### save_directory

Kind: Instance Variable

###### is_tensorboard

Kind: Instance Variable

###### is_wandb

Kind: Instance Variable

###### is_mlflow

Kind: Instance Variable

###### is_sweep

Kind: Instance Variable

###### rank

Kind: Instance Variable

###### local_logs

Kind: Instance Variable

###### mlflow_initialized

Kind: Instance Variable

###### run_id

Kind: Instance Variable

###### run_name

Kind: Instance Variable

###### rank_zero_only(fn: Callable) -> Callable: Callable

Kind: Static Method

Function wrapper that lets only processes with rank=0 execute
it.

###### log_to_mlflow(self, log_fn: Callable, args, kwargs)

Kind: Method

Attempts to log to MLflow, with retries.

Logs locally if failures persist.

###### store_log_locally(self, log_fn: Callable, args, kwargs)

Kind: Method

Stores log data locally if logging to MLflow fails.

###### log_stored_logs_to_mlflow(self)

Kind: Method

Attempts to log any data stored in local_logs to MLflow.

###### save_logs_locally(self)

Kind: Method

Saves metrics, parameters, images, artifacts, and matrices
locally.

###### name

Kind: Property

Returns run name.

###### version

Kind: Property

Returns tracker's version.

###### experiment

Kind: Property

Creates new experiments or returns active ones if already created.

###### log_hyperparams(self, params: Dict [ str , Union [ str , bool , int , float , None ] ])

Kind: Method

Logs hyperparameter dictionary.

@type params: Dict[str, Union[str, bool, int, float, None]]
@param params: Dict of hyperparameters key-value pairs.

###### log_metric(self, name: str, value: float, step: int)

Kind: Method

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

###### log_metrics(self, metrics: Dict [ str , float ], step: int)

Kind: Method

Logs metric dictionary.

@type metrics: Dict[str, float]
@param metrics: Dict of metric key-value pairs
@type step: int
@param step: Current step

###### log_image(self, name: str, img: np.ndarray, step: int)

Kind: Method

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

###### upload_artifact(self, path: PathType, name: Optional [ str ] = None, typ: str = 'artifact')

Kind: Method

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.

###### log_matrix(self, matrix: np.ndarray, name: str, step: int)

Kind: Method

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.

###### log_images(self, imgs: Dict [ str , np.ndarray ], step: int)

Kind: Method

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

###### close(self)

Kind: Method

Finalizes logging and saves unsent logs locally.

#### typing

Kind: Module

##### PathType: TypeAlias

Kind: Type Alias

A string or a `pathlib.Path` object.

##### PosixPathType: TypeAlias

Kind: Type Alias

A string or a `pathlib.PurePosixPath` object.

##### TaskType: TypeAlias

Kind: Type Alias

##### Labels: TypeAlias

Kind: Type Alias

Dictionary mappping task names to the annotations as C{np.ndarray}

##### LoaderOutput: TypeAlias

Kind: Type Alias

C{LoaderOutput} is a tuple of an image as a C{np.ndarray} and a
dictionary of task group names and their annotations as
L{Annotations}.

##### RGB: TypeAlias

Kind: Type Alias

##### HSV: TypeAlias

Kind: Type Alias

##### Color: TypeAlias

Kind: Type Alias

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).

##### Params: TypeAlias

Kind: Type Alias

A JSON-like dictionary of additioanl parameters.

##### luxonis_ml.typing.ConfigItem(pydantic.BaseModel)

Kind: Class

Configuration schema for dynamic object instantiation. Typically used to instantiate objects stored in registries.

A dictionary with a name and a dictionary of parameters.

###### name

Kind: Instance Variable

The name of the object this configuration applies to. Required.

###### params

Kind: Instance Variable

Additional parameters for instantiating the object. Not required.

#### utils

Kind: Package

##### config

Kind: Module

###### T

Kind: Type Variable

##### environ

Kind: Module

###### luxonis_ml.utils.environ.Environ(pydantic_settings.BaseSettings)

Kind: Class

A BaseSettings subclass for storing environment variables.

###### model_config

Kind: Class Variable

###### AWS_ACCESS_KEY_ID: Optional[str]

Kind: Constant

###### AWS_SECRET_ACCESS_KEY: Optional[str]

Kind: Constant

###### AWS_S3_ENDPOINT_URL: Optional[str]

Kind: Constant

###### MLFLOW_CLOUDFLARE_ID: Optional[str]

Kind: Constant

###### MLFLOW_CLOUDFLARE_SECRET: Optional[str]

Kind: Constant

###### MLFLOW_S3_BUCKET: Optional[str]

Kind: Constant

###### MLFLOW_S3_ENDPOINT_URL: Optional[str]

Kind: Constant

###### MLFLOW_TRACKING_URI: Optional[str]

Kind: Constant

###### POSTGRES_USER: Optional[str]

Kind: Constant

###### POSTGRES_PASSWORD: Optional[str]

Kind: Constant

###### POSTGRES_HOST: Optional[str]

Kind: Constant

###### POSTGRES_PORT: Optional[str]

Kind: Constant

###### POSTGRES_DB: Optional[str]

Kind: Constant

###### LUXONISML_BUCKET: Optional[str]

Kind: Constant

###### LUXONISML_BASE_PATH: Path

Kind: Constant

###### LUXONISML_TEAM_ID: str

Kind: Constant

###### LUXONISML_DISABLE_SETUP_LOGGING: bool

Kind: Constant

###### ROBOFLOW_API_KEY: Optional[str]

Kind: Constant

###### GOOGLE_APPLICATION_CREDENTIALS: Optional[str]

Kind: Constant

###### LOG_LEVEL: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']

Kind: Constant

###### environ

Kind: Variable

##### filesystem

Kind: Module

###### luxonis_ml.utils.filesystem.PutFile(typing.Protocol)

Kind: Class

###### __call__(self, local_path: PathType, remote_path: PosixPathType, mlflow_instance: Optional [ ModuleType ] = None) -> str:
str

Kind: Method

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

Kind: Class

###### MLFLOW: str

Kind: Constant

###### FSSPEC: str

Kind: Constant

##### logging

Kind: Module

##### pydantic_utils

Kind: Module

##### registry

Kind: Module

###### T

Kind: Type Variable

##### rich_utils

Kind: Module

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

Kind: Class

Class for storing configuration.

###### get_config

Kind: Class Method

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.

###### __str__(self) -> str: str

Kind: Method

###### __repr__(self) -> str: str

Kind: Method

###### get_json_schema(self) -> Params: Params

Kind: Method

Retuns dict representation of the config json schema.

@rtype: dict
@return: Dictionary with config json schema.

###### save_data(self, path: str)

Kind: Method

Saves config to a yaml file.

@type path: str
@param path: Path to output yaml file.

###### get(self, key_merged: str, default: Any = None) -> Any: Any

Kind: Method

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.

##### PUT_FILE_REGISTRY: Registry[PutFile]

Kind: Constant

##### luxonis_ml.utils.LuxonisFileSystem

Kind: Class

###### __init__(self, path: str, allow_active_mlflow_run: Optional [ bool ] = False, allow_local: Optional [ bool ] = True,
cache_storage: Optional [ str ] = None, put_file_plugin: Optional [ str ] = None)

Kind: Method

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}.

###### cache_storage

Kind: Instance Variable

###### url

Kind: Instance Variable

###### protocol

Kind: Instance Variable

###### allow_local

Kind: Instance Variable

###### fs_type

Kind: Instance Variable

###### allow_active_mlflow_run

Kind: Instance Variable

###### is_mlflow_active_run

Kind: Instance Variable

###### experiment_id

Kind: Instance Variable

###### run_id

Kind: Instance Variable

###### artifact_path

Kind: Instance Variable

###### tracking_uri

Kind: Instance Variable

###### path

Kind: Instance Variable

###### put_file(self, local_path: PathType, remote_path: PosixPathType, mlflow_instance: Optional [ ModuleType ] = None) -> str:
str

Kind: Method

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.

###### is_mlflow

Kind: Property

Returns True if the filesystem is MLFlow.

###### is_fsspec

Kind: Property

Returns True if the filesystem is fsspec.

###### full_path

Kind: Property

Returns full remote path.

###### init_fsspec_filesystem(self) -> fsspec.AbstractFileSystem: fsspec.AbstractFileSystem

Kind: Method

Initializes L{fsspec} filesystem based on the used protocol.

@rtype: L{fsspec.AbstractFileSystem}
@return: Initialized fsspec filesystem.

###### put_dir(self, local_paths: Union [ PathType , Iterable [ PathType ] ], remote_dir: PosixPathType, uuid_dict: Optional [
Dict [ str , str ] ] = None, mlflow_instance: Optional [ ModuleType ] = None, copy_contents: bool = False) -> Optional[Dict[str,
str]]: Optional[Dict[str, str]]

Kind: Method

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

###### put_bytes(self, file_bytes: bytes, remote_path: PosixPathType, mlflow_instance: Optional [ ModuleType ] = None)

Kind: Method

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.

###### get_file(self, remote_path: PosixPathType, local_path: PathType, mlflow_instance: Optional [ ModuleType ] = None) -> Path:
Path

Kind: Method

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.

###### delete_file(self, remote_path: PosixPathType)

Kind: Method

Deletes a single file from remote storage.

@type remote_path: PosixPathType
@param remote_path: Relative path to remote file

###### delete_files(self, remote_paths: List [ PosixPathType ])

Kind: Method

Deletes multiple files from remote storage.

@type remote_paths: List[PosixPathType]
@param remote_paths: Relative paths to remote files

###### get_dir(self, remote_paths: Union [ PosixPathType , Iterable [ PosixPathType ] ], local_dir: PathType, mlflow_instance:
Optional [ ModuleType ] = None) -> Path: Path

Kind: Method

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.

###### delete_dir(self, remote_dir: PosixPathType = '', allow_delete_parent: bool = False)

Kind: Method

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.

###### walk_dir(self, remote_dir: PosixPathType, recursive: bool = True, typ: Literal [ ' file ' , ' directory ' , ' all ' ] =
'file') -> Iterator[str]: Iterator[str]

Kind: Method

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.

###### read_text(self, remote_path: PosixPathType) -> Union[str, bytes]: Union[str, bytes]

Kind: Method

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.

###### read_to_byte_buffer(self, remote_path: Optional [ PosixPathType ] = None) -> BytesIO: BytesIO

Kind: Method

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.

###### get_file_uuid(self, path: PathType, local: bool = False) -> str: str

Kind: Method

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.

###### get_file_uuids(self, paths: Iterable [ PathType ], local: bool = False) -> Dict[str, str]: Dict[str, str]

Kind: Method

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

###### is_directory(self, remote_path: PosixPathType) -> bool: bool

Kind: Method

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.

###### exists(self, remote_path: PosixPathType = '') -> bool: bool

Kind: Method

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.

###### split_full_path(path: PathType) -> Tuple[str, str]: Tuple[str, str]

Kind: Static Method

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.

###### get_protocol(path: str) -> str: str

Kind: Static Method

Extracts the detected protocol from a path.

@type path: str
@param path: Full path
@rtype: str
@return: Protocol of the path.

###### download(url: str, dest: Optional [ PathType ]) -> Path: Path

Kind: Static Method

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.

###### upload(local_path: PathType, url: str)

Kind: Static Method

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.

##### deprecated(args: str, suggest: Optional [ Dict [ str , str ] ] = None, additional_message: Optional [ str ] = None,
altogether: bool = False)

Kind: Function

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.

##### setup_logging(level: Optional [ Literal [ ' DEBUG ' , ' INFO ' , ' WARNING ' , ' ERROR ' , ' CRITICAL ' ] ] = None, file:
Optional [ str ] = None, kwargs)

Kind: Function

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 kwargs: Any
@param kwargs: Additional keyword arguments to pass to
C{RichHandler}.

##### luxonis_ml.utils.BaseModelExtraForbid(pydantic.BaseModel)

Kind: Class

###### model_config: ConfigDict

Kind: Class Variable

##### luxonis_ml.utils.AutoRegisterMeta(abc.ABCMeta)

Kind: Class

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'>

###### REGISTRY: Registry

Kind: Class Variable

###### __new__(cls, name: str, bases: Tuple [ type , ... ], attrs: Dict [ str , type ], register: bool = True, register_name:
Optional [ str ] = None, registry: Optional [ Registry ] = None)

Kind: Method

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.

##### luxonis_ml.utils.Registry(typing.Generic)

Kind: Class

###### __init__(self, name: str)

Kind: Method

A Registry class to store and retrieve modules.

@type name: str
@ivar name: Name of the registry

###### __str__(self)

Kind: Method

###### __repr__(self)

Kind: Method

###### __len__(self)

Kind: Method

###### __getitem__(self, key: str) -> T: T

Kind: Method

###### __setitem__(self, key: str, value: T)

Kind: Method

###### name

Kind: Property

###### get(self, key: str) -> T: T

Kind: Method

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

###### register_module(self, name: Optional [ str ] = None, module: Optional [ T ] = None, force: bool = False) -> Union[T,
Callable[[T], T]]: Union[T, Callable[[T], T]]

Kind: Method

###### register(self, module: Optional [ T ] = None, name: Optional [ str ] = None, force: bool = False) -> Optional[Callable[[T],
T]]: Optional[Callable[[T], T]]

Kind: Method

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}

##### make_progress_bar() -> rich.progress.Progress: rich.progress.Progress

Kind: Function

#### __version__: str

Kind: Variable
