# API reference

0.4.5

### luxonis_train

Kind: Package

#### assigners

Kind: Package

##### atss_assigner

Kind: Module

##### tal_assigner

Kind: Module

##### utils

Kind: Module

###### candidates_in_gt(anchor_centers: Tensor, gt_bboxes: Tensor, eps: float = 1e-09) -> Tensor: Tensor

Kind: Function

Check if anchor box's center is in any GT bbox.

@type anchor_centers: Tensor
@param anchor_centers: Centers of anchor bboxes [n_anchors, 2]
@type gt_bboxes: Tensor
@param gt_bboxes: Ground truth bboxes [bs * n_max_boxes, 4]
@type eps: float
@param eps: Threshold for minimum delta. Defaults to 1e-9.
@rtype: Tensor
@return: Mask for anchors inside any GT bbox

###### fix_collisions(mask_pos: Tensor, overlaps: Tensor, n_max_boxes: int) -> tuple[Tensor, Tensor, Tensor]: tuple[Tensor,
Tensor, Tensor]

Kind: Function

If an anchor is assigned to multiple GTs, the one with highest
IoU is selected.

@type mask_pos: Tensor
@param mask_pos: Mask of assigned anchors [bs, n_max_boxes,
n_anchors]
@type overlaps: Tensor
@param overlaps: IoUs between GTs and anchors [bx, n_max_boxes,
n_anchors]
@type n_max_boxes: int
@param n_max_boxes: Number of maximum boxes per image
@rtype: tuple[Tensor, Tensor, Tensor]
@return: Assigned indices, sum of positive mask, positive mask

###### batch_iou(batch1: Tensor, batch2: Tensor) -> Tensor: Tensor

Kind: Function

Calculates IoU for each pair of bounding boxes in the batch.
Bounding boxes must be in the "xyxy" format.

@type batch1: Tensor
@param batch1: Tensor of shape C{[bs, N, 4]}
@type batch2: Tensor
@param batch2: Tensor of shape C{[bs, M, 4]}
@rtype: Tensor
@return: Per image box IoU of shape C{[bs, N, M]}

##### luxonis_train.assigners.ATSSAssigner(torch.nn.Module)

Kind: Class

###### __init__(self, n_classes: int, topk: int = 9)

Kind: Method

Adaptive Training Sample Selection Assigner, adapted
from U{Bridging the Gap Between Anchor-based and Anchor-free Detection via
Adaptive Training Sample Selection<https://arxiv.org/pdf/1912.02424.pdf>}.
Code is adapted from: U{https://github.com/Nioolek/PPYOLOE_pytorch/blob/master/
ppyoloe/assigner/atss_assigner.py} and
U{https://github.com/fcjian/TOOD/blob/master/mmdet/core/bbox/
assigners/atss_assigner.py}

@type n_classes: int
@param n_classes: Number of classes in the dataset.
@type topk: int
@param topk: Number of anchors considere in selection. Defaults to 9.

###### topk

Kind: Instance Variable

###### n_classes

Kind: Instance Variable

###### forward(self, anchor_bboxes: Tensor, n_level_bboxes: list [ int ], gt_labels: Tensor, gt_bboxes: Tensor, mask_gt: Tensor,
pred_bboxes: Tensor) -> tuple[Tensor, Tensor, Tensor, Tensor, Tensor]: tuple[Tensor, Tensor, Tensor, Tensor, Tensor]

Kind: Method

Assigner's forward method which generates final assignments.

@type anchor_bboxes: Tensor
@param anchor_bboxes: Anchor bboxes of shape [n_anchors, 4]
@type n_level_bboxes: list[int]
@param n_level_bboxes: Number of bboxes per level
@type gt_labels: Tensor
@param gt_labels: Initial GT labels [bs, n_max_boxes, 1]
@type gt_bboxes: Tensor
@param gt_bboxes: Initial GT bboxes [bs, n_max_boxes, 4]
@type mask_gt: Tensor
@param mask_gt: Mask for valid GTs [bs, n_max_boxes, 1]
@type pred_bboxes: Tensor
@param pred_bboxes: Predicted bboxes of shape [bs, n_anchors, 4]
@rtype: tuple[Tensor, Tensor, Tensor, Tensor, Tensor]
@return: Assigned labels of shape [bs, n_anchors], assigned
bboxes of shape [bs, n_anchors, 4], assigned scores of shape
[bs, n_anchors, n_classes] and output positive mask of shape
[bs, n_anchors].

###### n_anchors

Kind: Instance Variable

###### bs

Kind: Instance Variable

###### n_max_boxes

Kind: Instance Variable

##### luxonis_train.assigners.TaskAlignedAssigner(torch.nn.Module)

Kind: Class

###### __init__(self, n_classes: int, topk: int = 13, alpha: float = 1.0, beta: float = 6.0, eps: float = 1e-09, strides: Sequence
[ int ] | Tensor | None = None, skip_stal: bool = False)

Kind: Method

Task Aligned Assigner.

Adapted from: U{TOOD: Task-aligned One-stage Object Detection<https://arxiv.org/pdf/2108.07755.pdf>}.
Code is adapted from: U{https://github.com/Nioolek/PPYOLOE_pytorch/blob/master/ppyoloe/assigner/tal_assigner.py}.

@license: U{Apache License, Version 2.0<https://github.com/Nioolek/PPYOLOE_pytorch/
tree/master?tab=Apache-2.0-1-ov-file#readme>}

@type n_classes: int
@param n_classes: Number of classes in the dataset.
@type topk: int
@param topk: Number of anchors considered in selection. Defaults to 13.
@type alpha: float
@param alpha: Defaults to 1.0.
@type beta: float
@param beta: Defaults to 6.0.
@type eps: float
@param eps: Defaults to 1e-9.
@type strides: Sequence[int] | Tensor | None
@param strides: Detection strides (usually 8/16/32).
@type skip_stal: bool
@param skip_stal: If True, disables Small-Target-Aware Label
Assignment candidate expansion.

###### n_classes

Kind: Instance Variable

###### topk

Kind: Instance Variable

###### alpha

Kind: Instance Variable

###### beta

Kind: Instance Variable

###### eps

Kind: Instance Variable

###### strides

Kind: Instance Variable

###### skip_stal

Kind: Instance Variable

###### min_stride

Kind: Instance Variable

###### stal_target_size

Kind: Instance Variable

###### forward(self, pred_scores: Tensor, pred_bboxes: Tensor, anchor_points: Tensor, gt_labels: Tensor, gt_bboxes: Tensor,
mask_gt: Tensor, pred_kpts: Tensor | None = None, gt_kpts: Tensor | None = None, sigmas: Tensor | None = None, area_factor: float
| None = None) -> tuple[Tensor, Tensor, Tensor, Tensor, Tensor]: tuple[Tensor, Tensor, Tensor, Tensor, Tensor]

Kind: Method

Assigner's forward method which generates final assignments.

If both pred_kpts and gt_kpts are provided, a pose OKS is
computed and used in the alignment metric; the final tuple then
includes assigned poses.

@type pred_scores: Tensor
@param pred_scores: Predicted scores [bs, n_anchors, 1]
@type pred_bboxes: Tensor
@param pred_bboxes: Predicted bboxes [bs, n_anchors, 4]
@type anchor_points: Tensor
@param anchor_points: Anchor points [n_anchors, 2]
@type gt_labels: Tensor
@param gt_labels: Initial GT labels [bs, n_max_boxes, 1]
@type gt_bboxes: Tensor
@param gt_bboxes: Initial GT bboxes [bs, n_max_boxes, 4]
@type mask_gt: Tensor
@param mask_gt: Mask for valid GTs [bs, n_max_boxes, 1]
@type pred_kpts: Tensor | None
@param pred_kpts: Predicted keypoints [bs, n_anchors, n_kpts,
3] (optional)
@type gt_kpts: Tensor | None
@param gt_kpts: Ground truth keypoints [bs, n_max_boxes,
n_kpts, 3] (optional)
@type sigmas: Tensor | None
@param sigmas: Sigmas for OKS computation if keypoints are used.
@type area_factor: float | None
@param area_factor: Area factor for OKS computation. Defaults to
0.53.
@rtype: tuple[Tensor, Tensor, Tensor, Tensor, Tensor]
@return: Assigned labels of shape [bs, n_anchors], assigned
bboxes of shape [bs, n_anchors, 4], assigned scores of shape
[bs, n_anchors, n_classes] and output mask of shape [bs,
n_anchors]

###### bs

Kind: Instance Variable

###### n_max_boxes

Kind: Instance Variable

#### attached_modules

Kind: Package

##### base_attached_module

Kind: Module

###### luxonis_train.attached_modules.base_attached_module.BaseAttachedModule(torch.nn.Module, abc.ABC)

Kind: Class

Base class for all modules that are attached to a LuxonisNode.

Attached modules include losses, metrics and visualizers.

This class contains a default implementation of prepare method, which should be sufficient for most simple cases. More complex
modules should override the prepare method.

When subclassing, the following methods can be overridden:

prepare: Prepares node outputs for the forward pass of the module. Override this method if the default implementation is not
sufficient.

Additionally, the following attributes can be overridden:

supported_tasks: List of task types that the module supports. Used to determine which labels to extract from the dataset and to
validate compatibility with the node based on the node's tasks.

###### supported_tasks

Kind: Instance Variable

List of task types that the module supports. Elements of the list can be either a single task type or a tuple of task types. In
case of the latter, the module requires all of the specified labels in the tuple to be present.

###### __init__(self, node: BaseNode | None = None, kwargs)

Kind: Method

Constructor for teh C{BaseAttachedModule}

@type node: BaseNode
@param node: Reference to the node that this module is attached
to.
@param kwargs: Additional keyword arguments.

###### current_epoch

Kind: Property

###### task

Kind: Property

###### required_labels

Kind: Property

###### name

Kind: Property

###### node

Kind: Property

Reference to the node that this module is attached to.

###### n_keypoints

Kind: Property

Getter for the number of keypoints.

###### n_classes

Kind: Property

Getter for the number of classes.

###### original_in_shape

Kind: Property

Getter for the original input shape as [N, H, W].

###### classes

Kind: Property

Getter for the class mapping.

###### get_parameters(self, predictions: Packet [ Tensor ], labels: Labels | None = None) -> dict[str, (Tensor|list[Tensor])]:
dict[str, (Tensor|list[Tensor])]

Kind: Method

##### losses

Kind: Package

###### adaptive_detection_loss

Kind: Module

###### luxonis_train.attached_modules.losses.adaptive_detection_loss.VarifocalLoss(torch.nn.Module)

Kind: Class

###### __init__(self, alpha: float = 0.75, gamma: float = 2.0, per_class_weights: Tensor | None = None)

Kind: Method

Varifocal Loss is a loss function for training a dense object detector to predict
the IoU-aware classification score, inspired by focal loss.
Code is adapted from: U{https://github.com/Nioolek/PPYOLOE_pytorch/blob/master/ppyoloe/models/losses.py}

@type alpha: float
@param alpha: alpha parameter in focal loss, default is 0.75.
@type gamma: float
@param gamma: gamma parameter in focal loss, default is 2.0.
@type per_class_weights: Tensor | None
@param per_class_weights: A list of weights to scale the loss for each class during training. This allows you to emphasize or
de-emphasize certain classes based on their importance or representation in the dataset. The weights' length must be equal to the
number of classes.

###### alpha

Kind: Instance Variable

###### gamma

Kind: Instance Variable

###### per_class_weights

Kind: Instance Variable

###### forward(self, pred_score: Tensor, target_score: Tensor, label: Tensor) -> Tensor: Tensor

Kind: Method

###### base_loss

Kind: Module

###### bce_with_logits

Kind: Module

###### cross_entropy

Kind: Module

###### ctc_loss

Kind: Module

###### efficient_keypoint_bbox_loss

Kind: Module

###### embedding_losses

Kind: Module

###### EMBEDDING_LOSSES: list[str]

Kind: Constant

###### fomo_localization_loss

Kind: Module

###### ohem_loss

Kind: Module

###### precision_dfl_detection_loss

Kind: Module

###### luxonis_train.attached_modules.losses.precision_dfl_detection_loss.BBoxLoss(torch.nn.Module)

Kind: Class

###### __init__(self, reg_max: int = 16)

Kind: Method

BBox loss that combines IoU and DFL losses.

@type reg_max: int
@param reg_max: Maximum number of regression channels. Defaults
to 16.

###### dist_loss

Kind: Instance Variable

###### forward(self, pred_dist: Tensor, pred_bboxes: Tensor, anchors: Tensor, targets: Tensor, scores: Tensor, total_score:
Tensor, fg_mask: Tensor) -> tuple[Tensor, Tensor]: tuple[Tensor, Tensor]

Kind: Method

###### luxonis_train.attached_modules.losses.precision_dfl_detection_loss.DFLoss(torch.nn.Module)

Kind: Class

###### __init__(self, reg_max: int = 16)

Kind: Method

DFL loss that combines classification and regression losses.

@type reg_max: int
@param reg_max: Maximum number of regression channels. Defaults
to 16.

###### reg_max

Kind: Instance Variable

###### __call__(self, pred_dist: Tensor, targets: Tensor) -> Tensor: Tensor

Kind: Method

###### precision_dfl_segmentation_loss

Kind: Module

###### reconstruction_segmentation_loss

Kind: Module

###### luxonis_train.attached_modules.losses.reconstruction_segmentation_loss.SSIM(torch.nn.Module)

Kind: Class

###### __init__(self, window_size: int = 11, size_average: bool = True, val_range: float | None = None)

Kind: Method

###### window_size

Kind: Instance Variable

###### size_average

Kind: Instance Variable

###### val_range

Kind: Instance Variable

###### channel

Kind: Instance Variable

###### window

Kind: Instance Variable

###### forward(self, img1: Tensor, img2: Tensor) -> Tensor: Tensor

Kind: Method

###### create_window(window_size: int, channel: int = 1) -> Tensor: Tensor

Kind: Function

###### gaussian(window_size: int, sigma: float) -> Tensor: Tensor

Kind: Function

###### ssim(img1: Tensor, img2: Tensor, window_size: int = 11, window: Tensor | None = None, size_average: bool = True, val_range:
float | None = None) -> Tensor: Tensor

Kind: Function

###### sigmoid_focal_loss

Kind: Module

###### smooth_bce_with_logits

Kind: Module

###### softmax_focal_loss

Kind: Module

###### luxonis_train.attached_modules.losses.AdaptiveDetectionLoss(luxonis_train.attached_modules.losses.BaseLoss)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### node: EfficientBBoxHead

Kind: Class Variable

###### anchors

Kind: Instance Variable

###### anchor_points

Kind: Instance Variable

###### n_anchors_list

Kind: Instance Variable

###### stride_tensor

Kind: Instance Variable

###### gt_bboxes_scale

Kind: Instance Variable

###### __init__(self, n_warmup_epochs: int = 0, iou_type: IoUType = 'giou', reduction: Literal [ ' sum ' , ' mean ' ] = 'mean',
class_loss_weight: float = 1.0, iou_loss_weight: float = 2.5, per_class_weights: list [ float ] | None = None, skip_stal: bool =
False, kwargs)

Kind: Method

BBox loss adapted from U{YOLOv6: A Single-Stage Object Detection Framework for Industrial Applications
<https://arxiv.org/pdf/2209.02976.pdf>}. It combines IoU based bbox regression loss and varifocal loss
for classification.
Code is adapted from U{https://github.com/Nioolek/PPYOLOE_pytorch/blob/master/ppyoloe/models}.

@type n_warmup_epochs: int
@param n_warmup_epochs: Number of epochs where ATSS assigner is used, after that we switch to TAL assigner.
@type iou_type: L{IoUType}
@param iou_type: IoU type used for bbox regression loss.
@type reduction: Literal["sum", "mean"]
@param reduction: Reduction type for loss.
@type class_loss_weight: float
@param class_loss_weight: Weight of classification loss. Defaults to 1.0. For optimal results, multiply with
accumulate_grad_batches.
@type iou_loss_weight: float
@param iou_loss_weight: Weight of IoU loss. Defaults to 2.5. For optimal results, multiply with accumulate_grad_batches.
@type per_class_weights: list[float] | None
@param per_class_weights: A list of weights to scale the loss for each class during training. This allows you to emphasize or
de-emphasize certain classes based on their importance or representation in the dataset. The weights' length must be equal to the
number of classes.
@type skip_stal: bool
@param skip_stal: If True, disables the
Small-Target-Aware Label Assignment candidate expansion
when the loss switches to TAL after warmup.

###### iou_type

Kind: Instance Variable

###### reduction

Kind: Instance Variable

###### stride

Kind: Instance Variable

###### grid_cell_size

Kind: Instance Variable

###### grid_cell_offset

Kind: Instance Variable

###### original_img_size

Kind: Instance Variable

###### n_warmup_epochs

Kind: Instance Variable

###### atss_assigner

Kind: Instance Variable

###### tal_assigner

Kind: Instance Variable

###### per_class_weights

Kind: Instance Variable

###### varifocal_loss

Kind: Instance Variable

###### class_loss_weight

Kind: Instance Variable

###### iou_loss_weight

Kind: Instance Variable

###### forward(self, features: list [ Tensor ], class_scores: Tensor, distributions: Tensor, target: Tensor) -> tuple[Tensor,
dict[str, Tensor]]: tuple[Tensor, dict[str, Tensor]]

Kind: Method

###### anchor_points_strided

Kind: Instance Variable

###### luxonis_train.attached_modules.losses.BaseLoss(luxonis_train.attached_modules.BaseAttachedModule)

Kind: Class

A base class for all loss functions.

This class defines the basic interface for all loss functions. It utilizes automatic registration of defined subclasses to a
LOSSES registry.

###### __init__(self, final_loss_weight: float = 1.0, kwargs)

Kind: Method

@type weight: float
@param weight: Optional weight by which the final loss is multiplied.

###### forward(self, args: Tensor | list [ Tensor ]) -> Tensor|tuple[Tensor, dict[str, Tensor]]: Tensor|tuple[Tensor, dict[str,
Tensor]]

Kind: Method

Forward pass of the loss function.

@type *args: Tensor | list[Tensor] @param *args: Inputs to the
loss function.
@rtype: Tensor | tuple[Tensor, dict[str, Tensor]]
@return: The main loss and optional a dictionary of sub-losses
(for logging). Only the main loss is used for
backpropagation.

###### run(self, inputs: Packet [ Tensor ], labels: Labels) -> Tensor|tuple[Tensor, dict[str, Tensor]]: Tensor|tuple[Tensor,
dict[str, Tensor]]

Kind: Method

Calls the loss function.

Validates and prepares the inputs, then calls the loss function.

@type inputs: Packet[Tensor]
@param inputs: Outputs from the node.
@type labels: L{Labels}
@param labels: Labels from the dataset.
@rtype: Tensor | tuple[Tensor, dict[str, Tensor]]
@return: The main loss and optional a dictionary of sub-losses
(for logging). Only the main loss is used for
backpropagation.
@raises IncompatibleError: If the inputs are not compatible with
the module.

###### luxonis_train.attached_modules.losses.BCEWithLogitsLoss(luxonis_train.attached_modules.losses.BaseLoss)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### __init__(self, weight: list [ float ] | None = None, reduction: Literal [ ' none ' , ' mean ' , ' sum ' ] = 'mean',
pos_weight: Tensor | None = None, kwargs)

Kind: Method

This loss combines a L{nn.Sigmoid} layer and the
L{nn.BCELoss} in one single class. This version is more
numerically stable than using a plain C{Sigmoid} followed by a
{BCELoss} as, by combining the operations into one layer, we
take advantage of the log-sum-exp trick for numerical stability.

@type weight: list[float] | None
@param weight: a manual rescaling weight given to the loss of
each batch element. If given, has to be a list of length
C{nbatch}. Defaults to C{None}.
@type reduction: Literal["none", "mean", "sum"]
@param reduction: Specifies the reduction to apply to the
output: C{"none"} | C{"mean"} | C{"sum"}. C{"none"}: no
reduction will be applied, C{"mean"}: the sum of the output
will be divided by the number of elements in the output,
C{"sum"}: the output will be summed. Note: C{size_average}
and C{reduce} are in the process of being deprecated, and in
the meantime, specifying either of those two args will
override C{reduction}. Defaults to C{"mean"}.
@type pos_weight: Tensor | None
@param pos_weight: a weight of positive examples to be
broadcasted with target. Must be a tensor with equal size
along the class dimension to the number of classes. Pay
close attention to PyTorch's broadcasting semantics in order
to achieve the desired operations. For a target of size [B,
C, H, W] (where B is batch size) pos_weight of size [B, C,
H, W] will apply different pos_weights to each element of
the batch or [C, H, W] the same pos_weights across the
batch. To apply the same positive weight along all spacial
dimensions for a 2D multi-class target [C, H, W] use: [C, 1,
1]. Defaults to C{None}.

###### criterion

Kind: Instance Variable

###### forward(self, predictions: Tensor, target: Tensor) -> Tensor: Tensor

Kind: Method

Computes the BCE loss from logits.

@type predictions: Tensor
@param predictions: Network predictions of shape (N, C, ...)
@type target: Tensor
@param target: A tensor of the same shape as predictions.
@rtype: Tensor
@return: A scalar tensor.

###### luxonis_train.attached_modules.losses.CrossEntropyLoss(luxonis_train.attached_modules.losses.BaseLoss)

Kind: Class

This criterion computes the cross entropy loss between input logits and target.

###### supported_tasks

Kind: Class Variable

###### __init__(self, weight: list [ float ] | None = None, ignore_index: int = -100, reduction: Literal [ ' none ' , ' mean ' , '
sum ' ] = 'mean', label_smoothing: float = 0.0, kwargs)

Kind: Method

###### criterion

Kind: Instance Variable

###### forward(self, predictions: Tensor, target: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.attached_modules.losses.CTCLoss(luxonis_train.attached_modules.losses.BaseLoss)

Kind: Class

CTC loss with optional focal loss weighting.

###### node: OCRCTCHead

Kind: Class Variable

###### __init__(self, use_focal_loss: bool = True, kwargs)

Kind: Method

Initializes the CTC loss with optional focal loss support.

@type use_focal_loss: bool
@param use_focal_loss: Whether to apply focal loss weighting to
the CTC loss. Defaults to True.

###### loss_func

Kind: Instance Variable

###### use_focal_loss

Kind: Instance Variable

###### forward(self, predictions: Tensor, target: Tensor) -> Tensor: Tensor

Kind: Method

Computes the CTC loss, optionally applying focal loss.

@type preds: Tensor
@param preds: Network predictions of shape (B, T, C), where T is
the sequence length, B is the batch size, and C is the
number of classes.
@type targets: Tensor
@param targets: Encoded target sequences.
@rtype: Tensor
@return: The computed loss as a scalar tensor.

######
luxonis_train.attached_modules.losses.EfficientKeypointBBoxLoss(luxonis_train.attached_modules.losses.AdaptiveDetectionLoss)

Kind: Class

###### node: EfficientKeypointBBoxHead

Kind: Class Variable

###### supported_tasks

Kind: Class Variable

###### gt_kpts_scale

Kind: Instance Variable

###### __init__(self, n_warmup_epochs: int = 0, iou_type: IoUType = 'giou', reduction: Literal [ ' sum ' , ' mean ' ] = 'mean',
class_loss_weight: float = 0.5, iou_loss_weight: float = 7.5, viz_pw: float = 1.0, regr_kpts_loss_weight: float = 12,
vis_kpts_loss_weight: float = 1.0, sigmas: list [ float ] | None = None, area_factor: float | None = None, kwargs)

Kind: Method

BBox loss adapted from U{YOLOv6: A Single-Stage Object Detection Framework for Industrial Applications
<https://arxiv.org/pdf/2209.02976.pdf>}. It combines IoU based bbox regression loss and varifocal loss
for classification.
Code is adapted from U{https://github.com/Nioolek/PPYOLOE_pytorch/blob/master/ppyoloe/models}.

@type n_warmup_epochs: int
@param n_warmup_epochs: Number of epochs where ATSS assigner is used, after that we switch to TAL assigner.
@type iou_type: Literal["none", "giou", "diou", "ciou", "siou"]
@param iou_type: IoU type used for bbox regression loss.
@type reduction: Literal["sum", "mean"]
@param reduction: Reduction type for loss.
@type class_loss_weight: float
@param class_loss_weight: Weight of classification loss for bounding boxes.
@type regr_kpts_loss_weight: float
@param regr_kpts_loss_weight: Weight of regression loss for keypoints. Defaults to 12.0. For optimal results, multiply with
accumulate_grad_batches.
@type vis_kpts_loss_weight: float
@param vis_kpts_loss_weight: Weight of visibility loss for keypoints. Defaults to 1.0. For optimal results, multiply with
accumulate_grad_batches.
@type iou_loss_weight: float
@param iou_loss_weight: Weight of IoU loss. Defaults to 2.5. For optimal results, multiply with accumulate_grad_batches.
@type sigmas: list[float] | None
@param sigmas: Sigmas used in keypoint loss for OKS metric. If None then use COCO ones if possible or default ones. Defaults to
C{None}.
@type area_factor: float | None
@param area_factor: Factor by which we multiply bounding box area which is used in the keypoint loss.
If not set, the default factor of `0.53` is used.

###### b_cross_entropy

Kind: Instance Variable

###### sigmas

Kind: Instance Variable

###### area_factor

Kind: Instance Variable

###### regr_kpts_loss_weight

Kind: Instance Variable

###### vis_kpts_loss_weight

Kind: Instance Variable

###### forward(self, features: list [ Tensor ], class_scores: Tensor, distributions: Tensor, keypoints_raw: Tensor,
target_boundingbox: Tensor, target_keypoints: Tensor) -> tuple[Tensor, dict[str, Tensor]]: tuple[Tensor, dict[str, Tensor]]

Kind: Method

###### dist2kpts_noscale(self, anchor_points: Tensor, kpts: Tensor) -> Tensor: Tensor

Kind: Method

Adjusts and scales predicted keypoints relative to anchor
points without considering image stride.

###### luxonis_train.attached_modules.losses.EmbeddingLossWrapper(luxonis_train.attached_modules.losses.BaseLoss)

Kind: Class

###### node: GhostFaceNetHead

Kind: Class Variable

###### supported_tasks

Kind: Class Variable

###### miner

Kind: Instance Variable

###### __init__(self, miner: str | None = None, miner_params: Params | None = None, distance: str | None = None, distance_params:
Params | None = None, reducer: str | None = None, reducer_params: Params | None = None, regularizer: str | None = None,
regularizer_params: Params | None = None, node: BaseNode | None = None, final_loss_weight: float = 1.0, _loss_name: str =
_loss_name, kwargs)

Kind: Method

###### loss

Kind: Instance Variable

###### forward(self, predictions: Tensor, target: Tensor) -> Tensor: Tensor

Kind: Method

###### name

Kind: Property

###### luxonis_train.attached_modules.losses.FOMOLocalizationLoss(luxonis_train.attached_modules.losses.BaseLoss)

Kind: Class

###### node: FOMOHead

Kind: Class Variable

###### supported_tasks

Kind: Class Variable

###### __init__(self, object_weight: float = 500, alpha: float = 0.45, gamma: float = 2, kwargs)

Kind: Method

FOMO Localization Loss for object detection using heatmaps.

@type object_weight: float
@param object_weight: Weight multiplier for keypoint pixels in
loss calculation. Typical values range from 100-1000
depending on keypoint sparsity.
@type alpha: float
@param alpha: Focal loss alpha parameter for class balance (0-1
range). Lower values reduce positive example weighting.
@type gamma: float
@param gamma: Focal loss gamma parameter for hard example
focusing (gamma >= 0). Higher values focus more on hard
misclassified examples.

###### original_img_size

Kind: Instance Variable

###### object_weight

Kind: Instance Variable

###### alpha

Kind: Instance Variable

###### gamma

Kind: Instance Variable

###### forward(self, heatmap: Tensor, target: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.attached_modules.losses.OHEMLoss(luxonis_train.attached_modules.losses.BaseLoss)

Kind: Class

Generic OHEM loss that can be used with different criterions.

###### supported_tasks

Kind: Class Variable

###### __init__(self, criterion: str | type [ BaseLoss ] | Literal [ ' auto ' ] = 'auto', ohem_ratio: float = 0.1, ohem_threshold:
float = 0.7, kwargs)

Kind: Method

Initializes the criterion.

@type criterion: BaseLoss | str | Literal["auto"]
@param criterion: The criterion to use. It can be a string name
of the criterion (e.g., "CrossEntropyLoss"), a class that
inherits from C{BaseLoss}, or "auto" to infer the criterion
based on the task and other parameters.
@type ohem_ratio: float
@param ohem_ratio: The ratio of pixels to keep.
@type ohem_threshold: float
@param ohem_threshold: The threshold for pixels to keep.
@param kwargs: Additional keyword arguments that are passed to
the criterion.

###### criterion

Kind: Instance Variable

###### ohem_ratio

Kind: Instance Variable

###### ohem_threshold

Kind: Instance Variable

###### forward(self, predictions: Tensor, target: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.attached_modules.losses.PrecisionDFLDetectionLoss(luxonis_train.attached_modules.losses.BaseLoss)

Kind: Class

###### node: PrecisionBBoxHead

Kind: Class Variable

###### supported_tasks

Kind: Class Variable

###### __init__(self, tal_topk: int = 10, class_loss_weight: float = 0.5, bbox_loss_weight: float = 7.5, dfl_loss_weight: float =
1.5, skip_stal: bool = False, kwargs)

Kind: Method

BBox loss adapted from U{Real-Time Flying Object Detection with YOLOv8
<https://arxiv.org/pdf/2305.09972>} and from U{YOLOv6: A Single-Stage Object Detection Framework for Industrial Applications
<https://arxiv.org/pdf/2209.02976.pdf>}.
Code is adapted from U{https://github.com/Nioolek/PPYOLOE_pytorch/blob/master/ppyoloe/models}.

@type tal_topk: int
@param tal_topk: Number of anchors considered in selection. Defaults to 10.
@type class_loss_weight: float
@param class_loss_weight: Weight for classification loss. Defaults to 0.5. For optimal results, multiply with
accumulate_grad_batches.
@type bbox_loss_weight: float
@param bbox_loss_weight: Weight for bbox loss. Defaults to 7.5. For optimal results, multiply with accumulate_grad_batches.
@type dfl_loss_weight: float
@param dfl_loss_weight: Weight for DFL loss. Defaults to 1.5. For optimal results, multiply with accumulate_grad_batches.
@type skip_stal: bool
@param skip_stal: If True, disables the
Small-Target-Aware Label Assignment candidate expansion.
Defaults to False.

###### stride

Kind: Instance Variable

###### grid_cell_size

Kind: Instance Variable

###### grid_cell_offset

Kind: Instance Variable

###### original_img_size

Kind: Instance Variable

###### class_loss_weight

Kind: Instance Variable

###### bbox_loss_weight

Kind: Instance Variable

###### dfl_loss_weight

Kind: Instance Variable

###### assigner

Kind: Instance Variable

###### bbox_loss

Kind: Instance Variable

###### proj

Kind: Instance Variable

###### bce

Kind: Instance Variable

###### forward(self, features: list [ Tensor ], target: Tensor) -> tuple[Tensor, dict[str, Tensor]]: tuple[Tensor, dict[str,
Tensor]]

Kind: Method

###### decode_bbox(self, anchor_points: Tensor, pred_dist: Tensor) -> Tensor: Tensor

Kind: Method

Decode predicted object bounding box coordinates from anchor
points and distribution.

@type anchor_points: Tensor
@param anchor_points: Anchor points tensor of shape [N, 4] where
N is the number of anchors.
@type pred_dist: Tensor
@param pred_dist: Predicted distribution tensor of shape
[batch_size, N, 4 * reg_max] where N is the number of
anchors.
@rtype: Tensor

###### anchor_points

Kind: Instance Variable

###### stride_tensor

Kind: Instance Variable

###### gt_bboxes_scale

Kind: Instance Variable

###### anchor_points_strided

Kind: Instance Variable

######
luxonis_train.attached_modules.losses.PrecisionDFLSegmentationLoss(luxonis_train.attached_modules.losses.PrecisionDFLDetectionLoss)

Kind: Class

###### node: PrecisionSegmentBBoxHead

Kind: Class Variable

###### supported_tasks

Kind: Class Variable

###### __init__(self, tal_topk: int = 10, class_loss_weight: float = 0.5, bbox_loss_weight: float = 7.5, dfl_loss_weight: float =
1.5, skip_stal: bool = False, kwargs)

Kind: Method

Instance Segmentation and BBox loss adapted from U{Real-Time Flying Object Detection with YOLOv8
<https://arxiv.org/pdf/2305.09972>} and from U{YOLOv6: A Single-Stage Object Detection Framework for Industrial Applications
<https://arxiv.org/pdf/2209.02976.pdf>}.
Code is adapted from U{https://github.com/Nioolek/PPYOLOE_pytorch/blob/master/ppyoloe/models}.

@type tal_topk: int
@param tal_topk: Number of anchors considered in selection. Defaults to 10.
@type class_loss_weight: float
@param class_loss_weight: Weight for classification loss. Defaults to 0.5. For optimal results, multiply with
accumulate_grad_batches.
@type bbox_loss_weight: float
@param bbox_loss_weight: Weight for bbox loss. Defaults to 7.5. For optimal results, multiply with accumulate_grad_batches.
@type dfl_loss_weight: float
@param dfl_loss_weight: Weight for DFL loss. Defaults to 1.5. For optimal results, multiply with accumulate_grad_batches.
@type skip_stal: bool
@param skip_stal: If True, disables Small-Target-Aware Label Assignment candidate expansion. Defaults to False.

###### forward(self, features: list [ Tensor ], prototypes: Tensor, mask_coeficients: Tensor, target_boundingbox: Tensor,
target_instance_segmentation: Tensor) -> tuple[Tensor, dict[str, Tensor]]: tuple[Tensor, dict[str, Tensor]]

Kind: Method

###### compute_segmentation_loss(self, fg_mask: Tensor, gt_masks: Tensor, gt_idx: Tensor, bboxes: Tensor, batch_ids: Tensor,
proto: Tensor, pred_masks: Tensor) -> Tensor: Tensor

Kind: Method

Compute the segmentation loss for the entire batch.

@type fg_mask: Tensor
@param fg_mask: Foreground mask. Shape: (B, N_anchor).
@type gt_masks: Tensor
@param gt_masks: Ground truth masks. Shape: (n, H, W).
@type gt_idx: Tensor
@param gt_idx: Ground truth mask indices. Shape: (B, N_anchor).
@type bboxes: Tensor
@param bboxes: Ground truth bounding boxes in xyxy format.
Shape: (B, N_anchor, 4).
@type batch_ids: Tensor
@param batch_ids: Batch indices. Shape: (n, 1).
@type proto: Tensor
@param proto: Prototype masks. Shape: (B, 32, H, W).
@type pred_masks: Tensor
@param pred_masks: Predicted mask coefficients. Shape: (B,
N_anchor, 32).

###### luxonis_train.attached_modules.losses.ReconstructionSegmentationLoss(luxonis_train.attached_modules.losses.BaseLoss)

Kind: Class

###### node: DiscSubNetHead

Kind: Class Variable

###### supported_tasks

Kind: Class Variable

###### __init__(self, alpha: float = 1, gamma: float = 2.0, reduction: Literal [ ' none ' , ' mean ' , ' sum ' ] = 'mean', smooth:
float = 1e-05, kwargs)

Kind: Method

ReconstructionSegmentationLoss implements a combined loss
function for reconstruction and segmentation tasks.

It combines L2 loss for reconstruction, SSIM loss, and Focal
loss for segmentation.

@type alpha: float
@param alpha: Weighting factor for the rare class in the focal loss. Defaults to C{1}.
@type gamma: float
@param gamma: Focusing parameter for the focal loss. Defaults to C{2.0}.
@type smooth: float
@param smooth: Label smoothing factor for the focal loss. Defaults to C{0.0}.
@type reduction: Literal["none", "mean", "sum"]
@param reduction: Reduction type for the focal loss.. Defaults to C{"mean"}.

###### loss_l2

Kind: Instance Variable

###### loss_focal

Kind: Instance Variable

###### loss_ssim

Kind: Instance Variable

###### forward(self, predictions: Tensor, reconstruction: Tensor, target_original_segmentation: Tensor, target_segmentation:
Tensor) -> tuple[Tensor, dict[str, Tensor]]: tuple[Tensor, dict[str, Tensor]]

Kind: Method

###### luxonis_train.attached_modules.losses.SigmoidFocalLoss(luxonis_train.attached_modules.losses.BaseLoss)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### __init__(self, alpha: float = 0.25, gamma: float = 2.0, reduction: Literal [ ' none ' , ' mean ' , ' sum ' ] = 'mean',
kwargs)

Kind: Method

Focal loss from U{Focal Loss for Dense Object Detection
<https://arxiv.org/abs/1708.02002>}.

@type alpha: float
@param alpha: Weighting factor in range (0,1) to balance positive vs negative examples or -1 for ignore.
Defaults to C{0.25}.
@type gamma: float
@param gamma: Exponent of the modulating factor (1 - p_t) to balance easy vs hard examples.
Defaults to C{2.0}.
@type reduction: Literal["none", "mean", "sum"]
@param reduction: Reduction type for loss. Defaults to C{"mean"}.

###### alpha

Kind: Instance Variable

###### gamma

Kind: Instance Variable

###### reduction

Kind: Instance Variable

###### forward(self, predictions: Tensor, target: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.attached_modules.losses.SmoothBCEWithLogitsLoss(luxonis_train.attached_modules.losses.BaseLoss)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### __init__(self, label_smoothing: float = 0.0, bce_pow: float = 1.0, weight: list [ float ] | None = None, reduction: Literal
[ ' mean ' , ' sum ' , ' none ' ] = 'mean', kwargs)

Kind: Method

BCE with logits loss and label smoothing.

@type label_smoothing: float
@param label_smoothing: Label smoothing factor. Defaults to
C{0.0}.
@type bce_pow: float
@param bce_pow: Weight for positive samples. Defaults to C{1.0}.
@type weight: list[float] | None
@param weight: a manual rescaling weight given to the loss of
each batch element. If given, it has to be a list of length
C{nbatch}.
@type reduction: Literal["mean", "sum", "none"]
@param reduction: Specifies the reduction to apply to the
output: C{'none'} | C{'mean'} | C{'sum'}. C{'none'}: no
reduction will be applied, C{'mean'}: the sum of the output
will be divided by the number of elements in the output,
C{'sum'}: the output will be summed. Note: C{size_average}
and C{reduce} are in the process of being deprecated, and in
the meantime, specifying either of those two args will
override C{reduction}. Defaults to C{'mean'}.

###### positive_smooth_const

Kind: Instance Variable

###### negative_smooth_const

Kind: Instance Variable

###### criterion

Kind: Instance Variable

###### forward(self, predictions: Tensor, target: Tensor) -> Tensor: Tensor

Kind: Method

Computes the BCE loss with label smoothing.

@type predictions: Tensor
@param predictions: Network predictions of shape (N, C, ...)
@type target: Tensor
@param target: A tensor of the same shape as predictions.
@rtype: Tensor
@return: A scalar tensor.

###### luxonis_train.attached_modules.losses.SoftmaxFocalLoss(luxonis_train.attached_modules.losses.BaseLoss)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### __init__(self, alpha: float | list [ float ] = 0.25, gamma: float = 2.0, smooth: float = 0.0, reduction: Literal [ ' none '
, ' mean ' , ' sum ' ] = 'mean', kwargs)

Kind: Method

Focal loss implementation for classification and segmentation
tasks using Softmax.

@type alpha: float | list[float]
@param alpha: Weighting factor for the rare class. Defaults to
C{0.25}.
@type gamma: float
@param gamma: Focusing parameter. Defaults to C{2.0}.
@type smooth: float
@param smooth: Label smoothing factor. Defaults to C{0.0}.
@type reduction: Literal["none", "mean", "sum"]
@param reduction: Reduction type. Defaults to C{"mean"}.

###### gamma

Kind: Instance Variable

###### smooth

Kind: Instance Variable

###### reduction

Kind: Instance Variable

###### alpha

Kind: Instance Variable

###### forward(self, predictions: Tensor, targets: Tensor) -> Tensor: Tensor

Kind: Method

##### metrics

Kind: Package

###### base_metric

Kind: Module

###### confusion_matrix

Kind: Package

###### confusion_matrix

Kind: Module

###### detection_confusion_matrix

Kind: Module

###### fomo_confusion_matrix

Kind: Module

###### instance_segmentation_confusion_matrix

Kind: Module

###### recognition_confusion_matrix

Kind: Module

###### utils

Kind: Module

###### preprocess_instance_masks(predicted_boundingbox: list [ Tensor ], predicted_instance_segmentation: list [ Tensor ],
target_boundingbox: Tensor, target_instance_segmentation: Tensor, n_classes: int, height: int, width: int, device: torch.device)
-> tuple[Tensor, Tensor]: tuple[Tensor, Tensor]

Kind: Function

Turns an instance segmentation mask into a semantic one by
merging the masks of the same class.

###### compute_mcc(cm: Tensor) -> Tensor: Tensor

Kind: Function

" Compute the Matthews correlation coefficient from a confusion
matrix.

@type cm: Tensor
@param cm: Confusion matrix.
@rtype: Tensor
@return: Matthews correlation coefficient.

###### luxonis_train.attached_modules.metrics.confusion_matrix.ConfusionMatrix

Kind: Class

Factory class for Confusion Matrix metrics.

Creates the appropriate Confusion Matrix based on the task of the node.

###### __new__(cls, node: BaseNode, kwargs) ->
RecognitionConfusionMatrix|DetectionConfusionMatrix|InstanceSegmentationConfusionMatrix:
RecognitionConfusionMatrix|DetectionConfusionMatrix|InstanceSegmentationConfusionMatrix

Kind: Method

######
luxonis_train.attached_modules.metrics.confusion_matrix.DetectionConfusionMatrix(luxonis_train.attached_modules.metrics.BaseMetric)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### confusion_matrix: Tensor

Kind: Class Variable

###### __init__(self, iou_threshold: float = 0.45, kwargs)

Kind: Method

###### iou_threshold

Kind: Instance Variable

###### update(self, boundingbox: list [ Tensor ], target_boundingbox: Tensor)

Kind: Method

###### compute(self) -> dict[str, Tensor]: dict[str, Tensor]

Kind: Method

######
luxonis_train.attached_modules.metrics.confusion_matrix.FomoConfusionMatrix(luxonis_train.attached_modules.metrics.confusion_matrix.DetectionConfusionMatrix)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### __init__(self, iou_threshold: float | None = None, kwargs)

Kind: Method

###### update(self, keypoints: list [ Tensor ], target_boundingbox: Tensor)

Kind: Method

Override update to convert FOMO keypoints into bounding boxes
before calling the parent update method.

######
luxonis_train.attached_modules.metrics.confusion_matrix.InstanceSegmentationConfusionMatrix(luxonis_train.attached_modules.metrics.confusion_matrix.DetectionConfusionMatrix,
luxonis_train.attached_modules.metrics.confusion_matrix.RecognitionConfusionMatrix)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### update(self, boundingbox: list [ Tensor ], instance_segmentation: list [ Tensor ], target_boundingbox: Tensor,
target_instance_segmentation: Tensor)

Kind: Method

###### compute(self) -> dict[str, Tensor]: dict[str, Tensor]

Kind: Method

######
luxonis_train.attached_modules.metrics.confusion_matrix.RecognitionConfusionMatrix(luxonis_train.attached_modules.metrics.BaseMetric)

Kind: Class

Factory class for Recognition Confusion Matrix metrics.

Creates the appropriate confusion matrix metric based on the number of classes of the node.

###### supported_tasks

Kind: Class Variable

###### __init__(self, kwargs)

Kind: Method

###### metric

Kind: Instance Variable

###### update(self, predictions: Tensor, targets: Tensor)

Kind: Method

###### compute(self) -> dict[str, Tensor]: dict[str, Tensor]

Kind: Method

###### reset(self)

Kind: Method

###### dice_coefficient

Kind: Module

###### embedding_metrics

Kind: Module

###### mean_average_precision

Kind: Package

###### mean_average_precision

Kind: Module

###### mean_average_precision_bbox

Kind: Module

###### mean_average_precision_keypoints

Kind: Module

###### mean_average_precision_segmentation

Kind: Module

###### utils

Kind: Module

###### postprocess_metrics(metrics: dict [ str , Tensor ], class_names: Mapping [ int , str ], main_metric: str, device:
torch.device) -> tuple[Tensor, dict[str, Tensor]]: tuple[Tensor, dict[str, Tensor]]

Kind: Function

###### add_f1_metrics(metrics: dict [ str , Tensor ]) -> dict[str, Tensor]: dict[str, Tensor]

Kind: Function

###### process_class_metrics(metrics: dict [ str , Tensor ], class_names: Mapping [ int , str ]) -> dict[str, Tensor]: dict[str,
Tensor]

Kind: Function

###### compute_metric_lists(boundinbox: list [ Tensor ], target_boundingbox: Tensor, height: int, width: int, masks: list [ Tensor
] | None = None, target_masks: Tensor | None = None) -> tuple[list[dict[str, Tensor]], list[dict[str, Tensor]]]:
tuple[list[dict[str, Tensor]], list[dict[str, Tensor]]]

Kind: Function

###### luxonis_train.attached_modules.metrics.mean_average_precision.MeanAveragePrecision

Kind: Class

Factory class for Mean Average Precision (mAP) metrics.

Creates the appropriate mAP metric based on the task of the node.

###### get_predefined_model_params_aliases

Kind: Class Method

###### __new__(cls, node: BaseNode, kwargs) ->
MeanAveragePrecisionBBox|MeanAveragePrecisionSegmentation|MeanAveragePrecisionKeypoints:
MeanAveragePrecisionBBox|MeanAveragePrecisionSegmentation|MeanAveragePrecisionKeypoints

Kind: Method

######
luxonis_train.attached_modules.metrics.mean_average_precision.MeanAveragePrecisionBBox(luxonis_train.attached_modules.metrics.mean_average_precision.MeanAveragePrecision,
luxonis_train.attached_modules.metrics.BaseMetric)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### __init__(self, kwargs)

Kind: Method

###### update(self, boundingbox: list [ Tensor ], target_boundingbox: Tensor)

Kind: Method

###### compute(self) -> tuple[Tensor, dict[str, Tensor]]: tuple[Tensor, dict[str, Tensor]]

Kind: Method

######
luxonis_train.attached_modules.metrics.mean_average_precision.MeanAveragePrecisionKeypoints(luxonis_train.attached_modules.metrics.BaseMetric)

Kind: Class

Mean Average Precision metric for keypoints.

Uses OKS as IoU measure.

###### supported_tasks

Kind: Class Variable

###### pred_bboxes: Annotated[list[Tensor], MetricState()]

Kind: Class Variable

###### pred_scores: Annotated[list[Tensor], MetricState()]

Kind: Class Variable

###### pred_classes: Annotated[list[Tensor], MetricState()]

Kind: Class Variable

###### pred_keypoints: Annotated[list[Tensor], MetricState()]

Kind: Class Variable

###### target_bboxes: Annotated[list[Tensor], MetricState()]

Kind: Class Variable

###### target_classes: Annotated[list[Tensor], MetricState()]

Kind: Class Variable

###### target_keypoints: Annotated[list[Tensor], MetricState()]

Kind: Class Variable

###### __init__(self, sigmas: list [ float ] | None = None, area_factor: float | None = None, max_dets: int = 20, box_format:
Literal [ ' xyxy ' , ' xywh ' , ' cxcywh ' ] = 'xyxy', kwargs)

Kind: Method

Implementation of the mean average precision metric for
keypoint detections.

Adapted from: U{https://github.com/Lightning-AI/torchmetrics/blob/v1.0.1/src/
torchmetrics/detection/mean_ap.py}.

@license: Apache License, Version 2.0

@type sigmas: list[float] | None
@param sigmas: Sigma for each keypoint to weigh its importance, if C{None}, then
use COCO if possible otherwise defaults. Defaults to C{None}.
@type area_factor: float | None
@param area_factor: Factor by which we multiply the bounding box area.
If not set, the default factor of C{0.53} is used.
@type max_dets: int,
@param max_dets: Maximum number of detections to be considered per image. Defaults to C{20}.
@type box_format: Literal["xyxy", "xywh", "cxcywh"]
@param box_format: Input bounding box format. Defaults to C{"xyxy"}.

###### sigmas

Kind: Instance Variable

###### area_factor

Kind: Instance Variable

###### max_dets

Kind: Instance Variable

###### box_format

Kind: Instance Variable

###### update(self, keypoints: list [ Tensor ], boundingbox: list [ Tensor ], target_keypoints: Tensor, target_boundingbox:
Tensor)

Kind: Method

###### compute(self) -> tuple[Tensor, dict[str, Tensor]]: tuple[Tensor, dict[str, Tensor]]

Kind: Method

Torchmetric compute function.

###### coco_eval

Kind: Instance Variable

######
luxonis_train.attached_modules.metrics.mean_average_precision.MeanAveragePrecisionSegmentation(luxonis_train.attached_modules.metrics.mean_average_precision.MeanAveragePrecision,
luxonis_train.attached_modules.metrics.BaseMetric)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### __init__(self, kwargs)

Kind: Method

###### update(self, boundingbox: list [ Tensor ], instance_segmentation: list [ Tensor ], target_boundingbox: Tensor,
target_instance_segmentation: Tensor)

Kind: Method

###### compute(self) -> tuple[Tensor, dict[str, Tensor]]: tuple[Tensor, dict[str, Tensor]]

Kind: Method

###### mean_iou

Kind: Module

###### object_keypoint_similarity

Kind: Module

###### ocr_accuracy

Kind: Module

###### torchmetrics

Kind: Module

######
luxonis_train.attached_modules.metrics.torchmetrics.TorchMetricWrapper(luxonis_train.attached_modules.metrics.base_metric.BaseMetric)

Kind: Class

###### Metric: type[torchmetrics.Metric]

Kind: Class Variable

###### __init__(self, kwargs)

Kind: Method

###### metric

Kind: Instance Variable

###### update(self, predictions: Tensor, target: Tensor)

Kind: Method

###### compute(self) -> Tensor|tuple[Tensor, dict[str, Tensor]]: Tensor|tuple[Tensor, dict[str, Tensor]]

Kind: Method

###### reset(self)

Kind: Method

###### required_labels

Kind: Property

###### utils

Kind: Module

###### luxonis_train.attached_modules.metrics.BaseMetric(luxonis_train.attached_modules.BaseAttachedModule, torchmetrics.Metric)

Kind: Class

A base class for all metrics.

This class defines the basic interface for all metrics. It utilizes automatic registration of defined subclasses to a METRICS
registry.

###### predefined_model_params_aliases: ClassVar[dict[str, str]]

Kind: Class Variable

###### get_predefined_model_params_aliases

Kind: Class Method

###### __init__(self, kwargs)

Kind: Method

###### update(self, args: Tensor | list [ Tensor ])

Kind: Method

Updates the inner state of the metric.

@type args: Unpack[Ts]
@param args: Prepared inputs from the L{prepare} method.

###### compute(self) -> Tensor|tuple[Tensor, dict[str, Tensor]]|dict[str, Tensor]: Tensor|tuple[Tensor, dict[str,
Tensor]]|dict[str, Tensor]

Kind: Method

Computes the metric.

@rtype: Tensor | tuple[Tensor, dict[str, Tensor]] | dict[str, Tensor]
@return: The computed metric. Can be one of:
- A single Tensor.
- A tuple of a Tensor and a dictionary of sub-metrics.
- A dictionary of sub-metrics. If this is the case, then the metric
cannot be used as the main metric of the model.

###### run_update(self, inputs: Packet [ Tensor ], labels: Labels)

Kind: Method

Calls the metric's update method.

Validates and prepares the inputs, then calls the metric's
update method.

@type inputs: Packet[Tensor]
@param inputs: The outputs of the model.
@type labels: Labels
@param labels: The labels of the model. @raises
L{IncompatibleError}: If the inputs are not compatible with
the module.

###### luxonis_train.attached_modules.metrics.MetricState

Kind: Class

Marks an attribute that should be registered as a metric state. Intended to be used as a type hint for class attributes using the
`Annotated` type.

Upon initialization of a metric, all attributes of the metric that are marked as metric states will be registered using the
`add_state` method. The state will be accessible as an attribute of the metric instance.

Metric state variables are either Tensor or an empty list, which can be appended to by the metric. Metric states behave like
buffers and parameters of nn.Module as they are also updated when .to() is called. Unlike parameters and buffers, metric states
are not by default saved in the modules nn.Module.state_dict.

The metric state variables are automatically reset to their default values when the metric's reset() method is called.

Example usage:

class MyMetric(BaseMetric):
true_positives: Annotated[Tensor, MetricState(default=0)]
false_positives: Annotated[Tensor, MetricState(default=0)]
total: Annotated[Tensor, MetricState(default=0)]

###### default: Tensor|Number|list|None

Kind: Class Variable

###### dist_reduce_fx: Literal['sum', 'mean', 'cat', 'min', 'max']|Callable[[Tensor], Tensor]|Callable[[list[Tensor]],
Tensor]|EllipsisType|None

Kind: Class Variable

###### persistent: bool

Kind: Class Variable

###### luxonis_train.attached_modules.metrics.DiceCoefficient(luxonis_train.attached_modules.metrics.BaseMetric)

Kind: Class

Dice coefficient metric for SEGMENTATION tasks.

###### supported_tasks

Kind: Class Variable

###### __init__(self, num_classes: int, include_background: bool = True, average: Literal [ ' micro ' , ' macro ' , ' weighted ' ,
' none ' ] | None = 'micro', input_format: Literal [ ' one-hot ' , ' index ' ] = 'index', kwargs)

Kind: Method

Initializes the Dice coefficient metric.

@type num_classes: int
@param num_classes: Number of classes.
@type include_background: bool
@param include_background: Whether to include the background
class.
@type average: Literal["micro", "macro", "weighted", "none"]
@param average: Type of averaging.
@type input_format: Literal["one-hot", "index"]
@param input_format: Format of the input.

###### input_format

Kind: Instance Variable

###### metric

Kind: Instance Variable

###### convert_format(self, tensor: Tensor, is_target: bool = False) -> Tensor: Tensor

Kind: Method

###### update(self, predictions: Tensor, target: Tensor)

Kind: Method

###### compute(self) -> Tensor: Tensor

Kind: Method

###### reset(self)

Kind: Method

###### luxonis_train.attached_modules.metrics.ClosestIsPositiveAccuracy(luxonis_train.attached_modules.metrics.BaseMetric)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### node: GhostFaceNetHead

Kind: Class Variable

###### cross_batch_memory

Kind: Instance Variable

###### correct: Annotated[Tensor, MetricState()]

Kind: Class Variable

###### total: Annotated[Tensor, MetricState()]

Kind: Class Variable

###### __init__(self, kwargs)

Kind: Method

###### cross_batch_memory_size

Kind: Instance Variable

###### update(self, predictions: Tensor, target: Tensor)

Kind: Method

###### compute(self) -> Tensor: Tensor

Kind: Method

###### luxonis_train.attached_modules.metrics.MedianDistances(luxonis_train.attached_modules.metrics.BaseMetric)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### node: GhostFaceNetHead

Kind: Class Variable

###### cross_batch_memory

Kind: Instance Variable

###### all_distances: Annotated[list[Tensor], MetricState()]

Kind: Class Variable

###### closest_distances: Annotated[list[Tensor], MetricState()]

Kind: Class Variable

###### positive_distances: Annotated[list[Tensor], MetricState()]

Kind: Class Variable

###### closest_vs_positive_distances: Annotated[list[Tensor], MetricState()]

Kind: Class Variable

###### __init__(self, kwargs)

Kind: Method

###### cross_batch_memory_size

Kind: Instance Variable

###### update(self, embeddings: Tensor, target: Tensor)

Kind: Method

###### compute(self) -> dict[str, Tensor]: dict[str, Tensor]

Kind: Method

###### luxonis_train.attached_modules.metrics.MIoU(luxonis_train.attached_modules.metrics.BaseMetric)

Kind: Class

Mean IoU metric for SEGMENTATION tasks.

###### supported_tasks

Kind: Class Variable

###### predefined_model_params_aliases: dict[str, str]

Kind: Class Variable

###### __init__(self, num_classes: int, include_background: bool = True, per_class: bool = False, input_format: Literal [ '
one-hot ' , ' index ' ] = 'index', kwargs)

Kind: Method

Initializes the mean IoU metric.

@type num_classes: int
@param num_classes: Number of classes.
@type include_background: bool
@param include_background: Whether to include the background
class.
@type per_class: bool
@param per_class: Whether to compute the IoU per class.
@type input_format: Literal["one-hot", "index"]
@param input_format: Format of the input.

###### input_format

Kind: Instance Variable

###### include_background

Kind: Instance Variable

###### per_class

Kind: Instance Variable

###### metric

Kind: Instance Variable

###### convert_format(self, tensor: Tensor, is_target: bool = False) -> Tensor: Tensor

Kind: Method

###### update(self, predictions: Tensor, target: Tensor)

Kind: Method

###### compute(self) -> Tensor|tuple[Tensor, dict[str, Tensor]]: Tensor|tuple[Tensor, dict[str, Tensor]]

Kind: Method

###### reset(self)

Kind: Method

###### luxonis_train.attached_modules.metrics.ObjectKeypointSimilarity(luxonis_train.attached_modules.metrics.BaseMetric)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### pred_keypoints: Annotated[list[Tensor], MetricState()]

Kind: Class Variable

###### target_keypoints: Annotated[list[Tensor], MetricState()]

Kind: Class Variable

###### scales: Annotated[list[Tensor], MetricState()]

Kind: Class Variable

###### __init__(self, sigmas: list [ float ] | None = None, area_factor: float | None = None, use_cocoeval_oks: bool = True,
kwargs)

Kind: Method

Object Keypoint Similarity metric for evaluating keypoint
predictions.

@type sigmas: list[float] | None
@param sigmas: Sigma for each keypoint to weigh its importance,
if C{None}, then use COCO if possible otherwise defaults.
Defaults to C{None}.
@type area_factor: float | None
@param area_factor: Factor by which we multiply the bounding box
area. If not set, the default factor of C{0.53} is used.
@type use_cocoeval_oks: bool
@param use_cocoeval_oks: Whether to use same OKS formula as in
COCOeval or use the one from definition. Defaults to
C{True}.

###### sigmas

Kind: Instance Variable

###### area_factor

Kind: Instance Variable

###### use_cocoeval_oks

Kind: Instance Variable

###### update(self, keypoints: list [ Tensor ], target_boundingbox: Tensor, target_keypoints: Tensor | None = None)

Kind: Method

###### compute(self) -> Tensor: Tensor

Kind: Method

###### luxonis_train.attached_modules.metrics.OCRAccuracy(luxonis_train.attached_modules.metrics.BaseMetric)

Kind: Class

Accuracy metric for OCR tasks.

###### supported_tasks

Kind: Class Variable

###### node: OCRCTCHead

Kind: Class Variable

###### rank_0: Annotated[Tensor, MetricState()]

Kind: Class Variable

###### rank_1: Annotated[Tensor, MetricState()]

Kind: Class Variable

###### rank_2: Annotated[Tensor, MetricState()]

Kind: Class Variable

###### total: Annotated[Tensor, MetricState()]

Kind: Class Variable

###### __init__(self, blank_class: int = 0, kwargs)

Kind: Method

Initializes the OCR accuracy metric.

@type blank_class: int
@param blank_class: Index of the blank class. Defaults to C{0}.

###### blank_class

Kind: Instance Variable

###### update(self, predictions: Tensor, target: Tensor)

Kind: Method

Updates the running metric with the given predictions and
targets.

@type predictions: Tensor
@param predictions: A tensor containing the network predictions.
@type targets: Tensor
@param targets: A tensor containing the target labels.

###### compute(self) -> tuple[Tensor, dict[str, Tensor]]: tuple[Tensor, dict[str, Tensor]]

Kind: Method

Computes the OCR accuracy.

@rtype: tuple[Tensor, dict[str, Tensor]]
@return: A tuple containing the OCR accuracy and a dictionary of
individual accuracies.

###### luxonis_train.attached_modules.metrics.Accuracy(luxonis_train.attached_modules.metrics.torchmetrics.TorchMetricWrapper)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### luxonis_train.attached_modules.metrics.F1Score(luxonis_train.attached_modules.metrics.torchmetrics.TorchMetricWrapper)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### luxonis_train.attached_modules.metrics.JaccardIndex(luxonis_train.attached_modules.metrics.torchmetrics.TorchMetricWrapper)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### luxonis_train.attached_modules.metrics.Precision(luxonis_train.attached_modules.metrics.torchmetrics.TorchMetricWrapper)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### luxonis_train.attached_modules.metrics.Recall(luxonis_train.attached_modules.metrics.torchmetrics.TorchMetricWrapper)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### fix_empty_tensor(tensor: Tensor) -> Tensor: Tensor

Kind: Function

Empty tensors can cause problems in DDP mode, this methods
corrects them.

###### merge_bbox_kpt_targets(target_boundingbox: Tensor, target_keypoints: Tensor, device: torch.device | None = None) -> Tensor:
Tensor

Kind: Function

Merges the bounding box and keypoint targets into a single
tensor.

@param target_boundingbox: The bounding box targets.
@param target_keypoints: The keypoint targets.
@param device: The device to use.

##### visualizers

Kind: Package

###### base_visualizer

Kind: Module

###### Ts

Kind: Type Variable

###### bbox_visualizer

Kind: Module

###### classification_visualizer

Kind: Module

###### embeddings_visualizer

Kind: Module

###### fomo_visualizer

Kind: Module

###### instance_seg_keypoint_visualizer

Kind: Module

###### instance_segmentation_visualizer

Kind: Module

###### keypoint_visualizer

Kind: Module

###### ocr_visualizer

Kind: Module

###### segmentation_visualizer

Kind: Module

###### log_disable: bool

Kind: Variable

###### utils

Kind: Module

###### Color

Kind: Variable

###### figure_to_torch(fig: Figure, width: int, height: int) -> Tensor: Tensor

Kind: Function

Converts a matplotlib `Figure` to a `Tensor`.

###### torch_img_to_numpy(img: Tensor, reverse_colors: bool = False) -> npt.NDArray[np.uint8]: npt.NDArray[np.uint8]

Kind: Function

Converts a torch image (CHW) to a numpy array (HWC).

@type img: Tensor
@param img: Torch image (CHW)
@type reverse_colors: bool
@param reverse_colors: Whether to reverse colors (RGB to BGR).
Defaults to False.
@rtype: npt.NDArray[np.uint8]
@return: Numpy image (HWC)

###### numpy_to_torch_img(img: np.ndarray) -> Tensor: Tensor

Kind: Function

Converts numpy image (HWC) to torch image (CHW).

###### number_to_hsl(seed: int) -> tuple[float, float, float]: tuple[float, float, float]

Kind: Function

Map a number to a distinct HSL color.

###### hsl_to_rgb(hsl: tuple [ float , float , float ]) -> Color: Color

Kind: Function

Convert HSL color to RGB.

###### dynamically_determine_font_scale(height: int, width: int, thickness: int, font_scale: float | None = None, scale_factor:
float = 500.0) -> tuple[float, int]: tuple[float, int]

Kind: Function

###### potentially_upscale_masks(image_masks: Tensor, scale: float = 1.0) -> Tensor: Tensor

Kind: Function

Upscales boolean segmentation masks.

@param image_masks:
@param scale: scale factor
@return: Upscaled image masks

###### luxonis_train.attached_modules.visualizers.BaseVisualizer(luxonis_train.attached_modules.BaseAttachedModule)

Kind: Class

A base class for all visualizers.

This class defines the basic interface for all visualizers. It utilizes automatic registration of defined subclasses to the
VISUALIZERS registry.

###### __init__(self, args, scale: float = 1.0, kwargs)

Kind: Method

###### scale

Kind: Instance Variable

###### scale_canvas(canvas: Tensor, scale: float = 1.0) -> Tensor: Tensor

Kind: Static Method

###### forward(self, target_canvas: Tensor, prediction_canvas: Tensor, args: Unpack [ Ts ]) -> Tensor|tuple[Tensor,
Tensor]|tuple[Tensor, list[Tensor]]|list[Tensor]: Tensor|tuple[Tensor, Tensor]|tuple[Tensor, list[Tensor]]|list[Tensor]

Kind: Method

Forward pass of the visualizer.

Takes an image and the prepared inputs from the `prepare` method and
produces visualizations. Visualizations can be either:

- A single image (I{e.g.} for classification, weight visualization).
- A tuple of two images, representing (labels, predictions) (I{e.g.} for
bounding boxes, keypoints).
- A tuple of an image and a list of images,
representing (labels, multiple visualizations) (I{e.g.} for segmentation,
depth estimation).
- A list of images, representing unrelated visualizations.

@type target_canvas: Tensor
@param target_canvas: An image to draw the labels on.
@type prediction_canvas: Tensor
@param prediction_canvas: An image to draw the predictions on.
@type args: Unpack[Ts]
@param args: Prepared inputs from the `prepare` method.

@rtype: Tensor | tuple[Tensor, Tensor] | tuple[Tensor, list[Tensor]] | list[Tensor]
@return: Visualizations.

@raise IncompatibleError: If the inputs are not compatible with the module.

###### run(self, prediction_canvas: Tensor, target_canvas: Tensor, inputs: Packet [ Tensor ], labels: Labels | None) ->
Tensor|tuple[Tensor, Tensor]|tuple[Tensor, list[Tensor]]: Tensor|tuple[Tensor, Tensor]|tuple[Tensor, list[Tensor]]

Kind: Method

###### luxonis_train.attached_modules.visualizers.BBoxVisualizer(luxonis_train.attached_modules.visualizers.BaseVisualizer)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### __init__(self, labels: dict [ int , str ] | list [ str ] | None = None, draw_labels: bool = True, colors: dict [ str ,
Color ] | list [ Color ] | None = None, fill: bool = False, width: int | None = None, font: str | None = None, font_size: int |
None = None, kwargs)

Kind: Method

Visualizer for bounding box predictions.

Creates a visualization of the bounding box predictions and
labels.

@type labels: dict[int, str] | list[str] | None
@param labels: Either a dictionary mapping class indices to
names, or a list of names. If list is provided, the label
mapping is done by index. By default, no labels are drawn.
@type draw_labels: bool
@param draw_labels: Whether or not to draw labels. Defaults to
C{True}.
@type colors: dict[int, Color] | list[Color] | None
@param colors: Either a dictionary mapping class indices to
colors, or a list of colors. If list is provided, the color
mapping is done by index. By default, random colors are
used.
@type fill: bool
@param fill: Whether or not to fill the bounding boxes. Defaults
to C{False}.
@type width: int | None
@param width: The width of the bounding box lines. Defaults to
C{1}.
@type font: str | None
@param font: A filename containing a TrueType font. Defaults to
C{None}.
@type font_size: int | None
@param font_size: The font size to use for the labels. Defaults
to C{None}.

###### label_dict

Kind: Instance Variable

###### colors

Kind: Instance Variable

###### fill

Kind: Instance Variable

###### width

Kind: Instance Variable

###### font

Kind: Instance Variable

###### font_size

Kind: Instance Variable

###### draw_labels

Kind: Instance Variable

###### draw_targets(self, canvas: Tensor, targets: Tensor) -> Tensor: Tensor

Kind: Method

###### draw_predictions(self, canvas: Tensor, predictions: list [ Tensor ], scale: float = 1.0) -> Tensor: Tensor

Kind: Method

###### forward(self, prediction_canvas: Tensor, target_canvas: Tensor, predictions: list [ Tensor ], targets: Tensor | None) ->
tuple[Tensor, Tensor]|Tensor: tuple[Tensor, Tensor]|Tensor

Kind: Method

Creates a visualization of the bounding box predictions and
labels.

@type target_canvas: Tensor
@param target_canvas: The canvas containing the labels.
@type prediction_canvas: Tensor
@param prediction_canvas: The canvas containing the predictions.
@type prediction: Tensor
@param prediction: The predicted bounding boxes. The shape
should be [N, 6], where N is the number of bounding boxes
and the last dimension is [x1, y1, x2, y2, class, conf].
@type targets: Tensor
@param targets: The target bounding boxes.

######
luxonis_train.attached_modules.visualizers.ClassificationVisualizer(luxonis_train.attached_modules.visualizers.BaseVisualizer)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### __init__(self, include_plot: bool = True, font_scale: float | None = None, color: tuple [ int , int , int ] = (255, 0, 0),
thickness: int = 2, multilabel: bool = False, kwargs)

Kind: Method

Visualizer for classification tasks.

@type include_plot: bool
@param include_plot: Whether to include a plot of the class
probabilities in the visualization. Defaults to C{True}.
@type font_scale: float | None = None,
@param font_scale: Font scale for text. If None, scales
proportionally to the image height and width

###### include_plot

Kind: Instance Variable

###### font_scale

Kind: Instance Variable

###### color

Kind: Instance Variable

###### thickness

Kind: Instance Variable

###### multilabel

Kind: Instance Variable

###### forward(self, prediction_canvas: Tensor, target_canvas: Tensor, predictions: Tensor, target: Tensor | None) ->
Tensor|tuple[Tensor, Tensor]: Tensor|tuple[Tensor, Tensor]

Kind: Method

###### luxonis_train.attached_modules.visualizers.EmbeddingsVisualizer(luxonis_train.attached_modules.visualizers.BaseVisualizer)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### __init__(self, z_score_threshold: float = 3, kwargs)

Kind: Method

Visualizer for embedding tasks like reID.

@type z_score_threshold: float
@param z_score_threshold: The threshold for filtering out
outliers.

###### colors

Kind: Instance Variable

###### z_score_threshold

Kind: Instance Variable

###### forward(self, prediction_canvas: Tensor, target_canvas: Tensor, predictions: Tensor, target: Tensor) -> tuple[Tensor,
Tensor]: tuple[Tensor, Tensor]

Kind: Method

Creates a visualization of the embeddings.

@type target_canvas: Tensor
@param target_canvas: The canvas to draw the labels on.
@type prediction_canvas: Tensor
@param prediction_canvas: The canvas to draw the predictions on.
@type embeddings: Tensor
@param embeddings: The embeddings to visualize.
@type target: Tensor
@param target: Ids of the embeddings.
@rtype: Tensor
@return: An embedding space projection.

###### plot_to_tensor(embeddings_2d: np.ndarray, ids_np: np.ndarray, plot_func: Callable [ [ plt.Axes , np.ndarray , np.ndarray ]
, None ]) -> Tensor: Tensor

Kind: Static Method

###### kde_plot(self, ax: plt.Axes, emb: np.ndarray, labels: np.ndarray)

Kind: Method

###### scatter_plot(self, ax: plt.Axes, emb: np.ndarray, labels: np.ndarray)

Kind: Method

###### luxonis_train.attached_modules.visualizers.FOMOVisualizer(luxonis_train.attached_modules.visualizers.BBoxVisualizer)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### __init__(self, visibility_threshold: float = 0.5, radius: int = 5, kwargs)

Kind: Method

###### visibility_threshold

Kind: Instance Variable

###### radius

Kind: Instance Variable

###### forward(self, prediction_canvas: Tensor, target_canvas: Tensor, keypoints: list [ Tensor ], target_boundingbox: Tensor |
None) -> tuple[Tensor, Tensor]|Tensor: tuple[Tensor, Tensor]|Tensor

Kind: Method

###### draw_predictions_per_class(self, canvas: Tensor, predictions: list [ Tensor ]) -> Tensor: Tensor

Kind: Method

######
luxonis_train.attached_modules.visualizers.InstanceSegKeypointVisualizer(luxonis_train.attached_modules.visualizers.BaseVisualizer)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### __init__(self, labels: dict [ int , str ] | list [ str ] | None = None, draw_labels: bool = True, colors: dict [ str ,
Color ] | list [ Color ] | None = None, fill: bool = False, width: int | None = None, font: str | None = None, font_size: int |
None = None, alpha: float = 0.6, visibility_threshold: float = 0.5, connectivity: list [ tuple [ int , int ] ] | None = None,
visible_color: Color = 'red', nonvisible_color: Color | None = None, radius: int | None = None, draw_indices: bool = False,
kwargs)

Kind: Method

@type labels: dict[int, str] | list[str] | None
@param labels: Dictionary mapping class indices to class labels.
@type draw_labels: bool
@param draw_labels: Whether to draw class labels.
@type colors: dict[str, L{Color}] | list[L{Color}] | None
@param colors: Dictionary mapping class labels to colors.
@type fill: bool
@param fill: Whether to fill bounding boxes.
@type width: int | None
@param width: Width of the bounding box lines.
@type font: str | None
@param font: TrueType font filename.
@type font_size: int | None
@param font_size: Font size for labels.
@type alpha: float
@param alpha: Alpha value for segmentation masks.
@type visibility_threshold: float
@param visibility_threshold: Threshold for keypoint visibility.
@type connectivity: list[tuple[int, int]] | None
@param connectivity: Keypoint skeleton connections.
@type visible_color: L{Color}
@param visible_color: Color for visible keypoints.
@type nonvisible_color: L{Color} | None
@param nonvisible_color: Color for non-visible keypoints.
@type radius: int | None
@param radius: Keypoint radius.
@type draw_indices: bool
@param draw_indices: Whether to draw keypoint indices.

###### bbox_labels

Kind: Instance Variable

###### colors

Kind: Instance Variable

###### fill

Kind: Instance Variable

###### width

Kind: Instance Variable

###### font

Kind: Instance Variable

###### font_size

Kind: Instance Variable

###### draw_labels

Kind: Instance Variable

###### alpha

Kind: Instance Variable

###### visibility_threshold

Kind: Instance Variable

###### connectivity

Kind: Instance Variable

###### visible_color

Kind: Instance Variable

###### nonvisible_color

Kind: Instance Variable

###### radius

Kind: Instance Variable

###### draw_indices

Kind: Instance Variable

###### forward(self, prediction_canvas: Tensor, target_canvas: Tensor, boundingbox: list [ Tensor ], instance_segmentation: list [
Tensor ], keypoints: list [ Tensor ], target_boundingbox: Tensor | None, target_instance_segmentation: Tensor | None,
target_keypoints: Tensor | None) -> tuple[Tensor, Tensor]|Tensor: tuple[Tensor, Tensor]|Tensor

Kind: Method

######
luxonis_train.attached_modules.visualizers.InstanceSegmentationVisualizer(luxonis_train.attached_modules.visualizers.BaseVisualizer)

Kind: Class

Visualizer for instance segmentation tasks, supporting the visualization of predicted and ground truth bounding boxes and instance
segmentation masks.

###### supported_tasks

Kind: Class Variable

###### __init__(self, labels: dict [ int , str ] | list [ str ] | None = None, draw_labels: bool = True, colors: dict [ str ,
Color ] | list [ Color ] | None = None, fill: bool = False, width: int | None = None, font: str | None = None, font_size: int |
None = None, alpha: float = 0.6, kwargs)

Kind: Method

Visualizer for instance segmentation tasks.

@type labels: dict[int, str] | list[str] | None
@param labels: Dictionary mapping class indices to class labels.
@type draw_labels: bool
@param draw_labels: Whether to draw class labels on the
visualizations.
@type colors: dict[str, L{Color}] | list[L{Color}] | None
@param colors: Dicionary mapping class labels to colors.
@type fill: bool | None
@param fill: Whether to fill the boundingbox with color.
@type width: int | None
@param width: Width of the bounding box Lines.
@type font: str | None
@param font: Font of the clas labels.
@type font_size: int | None
@param font_size: Font size of the class Labels.
@type alpha: float
@param alpha: Alpha value of the segmentation masks. Defaults to
C{0.6}.

###### bbox_labels

Kind: Instance Variable

###### colors

Kind: Instance Variable

###### fill

Kind: Instance Variable

###### width

Kind: Instance Variable

###### font

Kind: Instance Variable

###### font_size

Kind: Instance Variable

###### draw_labels

Kind: Instance Variable

###### alpha

Kind: Instance Variable

###### draw_predictions(canvas: Tensor, pred_bboxes: list [ Tensor ], pred_masks: list [ Tensor ], width: int | None, label_dict:
Mapping [ int , str ], color_dict: dict [ str , Color ], draw_labels: bool, alpha: float, scale: float = 1.0) -> Tensor: Tensor

Kind: Static Method

###### draw_targets(canvas: Tensor, target_bboxes: Tensor, target_masks: Tensor, width: int | None, label_dict: Mapping [ int ,
str ], color_dict: dict [ str , Color ], draw_labels: bool, alpha: float, scale: float = 1.0) -> Tensor: Tensor

Kind: Static Method

###### forward(self, prediction_canvas: Tensor, target_canvas: Tensor, boundingbox: list [ Tensor ], instance_segmentation: list [
Tensor ], target_boundingbox: Tensor | None, target_instance_segmentation: Tensor | None) -> tuple[Tensor, Tensor]|Tensor:
tuple[Tensor, Tensor]|Tensor

Kind: Method

Creates visualizations of the predicted and target bounding
boxes and instance masks.

@type target_canvas: Tensor
@param target_canvas: Tensor containing the target
visualizations.
@type prediction_canvas: Tensor
@param prediction_canvas: Tensor containing the predicted
visualizations.
@type target_bboxes: Tensor | None
@param target_bboxes: Tensor containing the target bounding
boxes.
@type target_masks: Tensor | None
@param target_masks: Tensor containing the target instance
masks.
@type predicted_bboxes: list[Tensor]
@param predicted_bboxes: List of tensors containing the
predicted bounding boxes.
@type predicted_masks: list[Tensor]
@param predicted_masks: List of tensors containing the predicted
instance masks.

###### luxonis_train.attached_modules.visualizers.KeypointVisualizer(luxonis_train.attached_modules.visualizers.BBoxVisualizer)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### __init__(self, visibility_threshold: float = 0.5, connectivity: list [ tuple [ int , int ] ] | None = None, visible_color:
Color = 'red', nonvisible_color: Color | None = None, radius: int | None = None, draw_indices: bool = False, kwargs)

Kind: Method

Visualizer for keypoints.

@type visibility_threshold: float
@param visibility_threshold: Threshold for visibility of
keypoints. If the visibility of a keypoint is below this
threshold, it is considered as not visible. Defaults to
C{0.5}.
@type connectivity: list[tuple[int, int]] | None
@param connectivity: List of tuples of keypoint indices that
define the connections in the skeleton. Defaults to C{None}.
@type visible_color: L{Color}
@param visible_color: Color of visible keypoints. Either a
string or a tuple of RGB values. Defaults to C{"red"}.
@type nonvisible_color: L{Color} | None
@param nonvisible_color: Color of nonvisible keypoints. If
C{None}, nonvisible keypoints are not drawn. Defaults to
C{None}.
@type radius: int | None
@param radius: the radius of drawn keypoints

###### visibility_threshold

Kind: Instance Variable

###### connectivity

Kind: Instance Variable

###### visible_color

Kind: Instance Variable

###### nonvisible_color

Kind: Instance Variable

###### radius

Kind: Instance Variable

###### draw_indices

Kind: Instance Variable

###### draw_predictions(canvas: Tensor, predictions: list [ Tensor ], draw_indices: bool = False, nonvisible_color: Color | None =
None, visible_color: Color = 'red', visibility_threshold: float = 0.5, radius: int | None = None, scale: float = 1.0, kwargs) ->
Tensor: Tensor

Kind: Static Method

###### draw_keypoint_indices_pil(canvas: Tensor, keypoints: Tensor, offset: tuple [ int , int ] = (7, 7), colors: Color = 'red')
-> Tensor: Tensor

Kind: Static Method

Draw keypoint indices using PIL, cycling text offsets to
reduce overlap.

Text is centered around each keypoint, so offsets behave
symmetrically.

###### draw_targets(canvas: Tensor, targets: Tensor, draw_indices: bool = False, colors: Color = 'red', kwargs) -> Tensor: Tensor

Kind: Static Method

###### forward(self, prediction_canvas: Tensor, target_canvas: Tensor, keypoints: list [ Tensor ], boundingbox: list [ Tensor ],
target_keypoints: Tensor | None, target_boundingbox: Tensor | None, kwargs) -> tuple[Tensor, Tensor]|Tensor: tuple[Tensor,
Tensor]|Tensor

Kind: Method

###### luxonis_train.attached_modules.visualizers.OCRVisualizer(luxonis_train.attached_modules.visualizers.BaseVisualizer)

Kind: Class

Visualizer for OCR tasks.

###### node: OCRCTCHead

Kind: Class Variable

###### __init__(self, font_scale: float = 0.5, color: tuple [ int , int , int ] = (0, 0, 0), thickness: int = 1, kwargs)

Kind: Method

Initializes the OCR visualizer.

@type font_scale: float
@param font_scale: Font scale of the text. Defaults to C{0.5}.
@type color: tuple[int, int, int]
@param color: Color of the text. Defaults to C{(0, 0, 0)}.
@type thickness: int
@param thickness: Thickness of the text. Defaults to C{1}.

###### font_scale

Kind: Instance Variable

###### color

Kind: Instance Variable

###### thickness

Kind: Instance Variable

###### forward(self, prediction_canvas: Tensor, target_canvas: Tensor, predictions: Tensor, targets: Tensor | None) ->
tuple[Tensor, Tensor]: tuple[Tensor, Tensor]

Kind: Method

Creates a visualization of the OCR predictions and labels.

@type label_canvas: Tensor
@param label_canvas: The canvas to draw the labels on.
@type prediction_canvas: Tensor
@param prediction_canvas: The canvas to draw the predictions on.
@type predictions: list[str]
@param predictions: The predictions to visualize.
@type targets: list[str]
@param targets: The targets to visualize.
@rtype: tuple[Tensor, Tensor]
@return: A tuple of the label and prediction visualizations.

######
luxonis_train.attached_modules.visualizers.SegmentationVisualizer(luxonis_train.attached_modules.visualizers.BaseVisualizer)

Kind: Class

###### supported_tasks

Kind: Class Variable

###### __init__(self, colors: Color | list [ Color ] | None = None, background_class: int | None = 0, background_color: Color =
'#000000', alpha: float = 0.6, kwargs)

Kind: Method

Visualizer for segmentation tasks.

@type colors: L{Color} | list[L{Color}]
@param colors: Color of the segmentation masks. Defaults to C{"#5050FF"}.
@type background_class: int | None
@param background_class: Index of the background class. Defaults to C{0}.
If set, the background class will be drawn with the `background_color`.
@type background_color: L{Color} | None
@param background_color: Color of the background class.
Defaults to C{"#000000"}.
@type alpha: float
@param alpha: Alpha value of the segmentation masks. Defaults to C{0.6}.

###### colors

Kind: Instance Variable

###### background_class

Kind: Instance Variable

###### background_color

Kind: Instance Variable

###### alpha

Kind: Instance Variable

###### colormap

Kind: Instance Variable

###### draw_predictions(canvas: Tensor, predictions: Tensor, alpha: float, colors: list [ Color ], scale: float = 1.0) -> Tensor:
Tensor

Kind: Static Method

###### draw_targets(canvas: Tensor, targets: Tensor, alpha: float, colors: list [ Color ], scale: float = 1.0) -> Tensor: Tensor

Kind: Static Method

###### forward(self, prediction_canvas: Tensor, target_canvas: Tensor, predictions: Tensor, target: Tensor | None) ->
tuple[Tensor, Tensor]|Tensor: tuple[Tensor, Tensor]|Tensor

Kind: Method

Creates a visualization of the segmentation predictions and
labels.

@type target_canvas: Tensor
@param target_canvas: The canvas to draw the labels on.
@type prediction_canvas: Tensor
@param prediction_canvas: The canvas to draw the predictions on.
@type predictions: Tensor
@param predictions: The predictions to visualize.
@type targets: Tensor
@param targets: The targets to visualize.
@rtype: tuple[Tensor, Tensor]
@return: A tuple of the label and prediction visualizations.

###### required_labels

Kind: Property

###### combine_visualizations(visualization: Tensor | tuple [ Tensor , Tensor ] | tuple [ Tensor , list [ Tensor ] ]) -> Tensor:
Tensor

Kind: Function

Default way of combining multiple visualizations into one final
image.

###### denormalize(img: Tensor, mean: list [ float ] | float | None = None, std: list [ float ] | float | None = None, to_uint8:
bool = False) -> Tensor: Tensor

Kind: Function

Denormalizes an image back to original values, optionally
converts it to uint8.

@type img: Tensor
@param img: Image to denormalize.
@type mean: list[float] | float | None
@param mean: Mean used for denormalization. Defaults to C{None}.
@type std: list[float] | float | None
@param std: Std used for denormalization. Defaults to C{None}.
@type to_uint8: bool
@param to_uint8: Whether to convert to uint8. Defaults to C{False}.
@rtype: Tensor
@return: denormalized image.

###### draw_bounding_box_labels(img: Tensor, label: Tensor, kwargs) -> Tensor: Tensor

Kind: Function

Draws bounding box labels on an image.

@type img: Tensor
@param img: Image to draw on.
@type label: Tensor
@param label: Bounding box label. The shape should be (n_instances,
4), where the last dimension is (x, y, w, h).
@type kwargs: dict
@param kwargs: Additional arguments to pass to
L{torchvision.utils.draw_bounding_boxes}.
@rtype: Tensor
@return: Image with bounding box labels drawn on.

###### draw_keypoint_labels(img: Tensor, label: Tensor, kwargs) -> Tensor: Tensor

Kind: Function

Draws keypoint labels on an image.

@type img: Tensor
@param img: Image to draw on.
@type label: Tensor
@param label: Keypoint label. The shape should be (n_instances, 3),
where the last dimension is (x, y, visibility).
@type kwargs: dict
@param kwargs: Additional arguments to pass to
L{torchvision.utils.draw_keypoints}.
@rtype: Tensor
@return: Image with keypoint labels drawn on.

###### draw_segmentation_targets(image: Tensor, target: Tensor, alpha: float = 0.4, colors: Color | list [ Color ] | None = None)
-> Tensor: Tensor

Kind: Function

Draws segmentation labels on an image.

@type image: Tensor
@param image: Image to draw on.
@type target: Tensor
@param target: Segmentation label.
@type alpha: float
@param alpha: Alpha value for blending. Defaults to C{0.4}.
@rtype: Tensor
@return: Image with segmentation labels drawn on.

###### get_color(seed: int) -> Color: Color

Kind: Function

Generates a random color from a seed.

@type seed: int
@param seed: Seed to use for the generator.
@rtype: L{Color}
@return: Generated color.

###### get_denormalized_images(cfg: Config, images: Tensor) -> Tensor: Tensor

Kind: Function

###### preprocess_images(imgs: Tensor, mean: list [ float ] | float | None = None, std: list [ float ] | float | None = None) ->
Tensor: Tensor

Kind: Function

Performs preprocessing on a batch of images.

Preprocessing includes denormalizing and converting to uint8.

@type imgs: Tensor
@param imgs: Batch of images.
@type mean: list[float] | float | None
@param mean: Mean used for denormalization. Defaults to C{None}.
@type std: list[float] | float | None
@param std: Std used for denormalization. Defaults to C{None}.
@rtype: Tensor
@return: Batch of preprocessed images.

#### callbacks

Kind: Package

##### archive_on_train_end

Kind: Module

##### convert_on_train_end

Kind: Module

##### ema

Kind: Module

###### luxonis_train.callbacks.ema.ModelEma(torch.nn.Module)

Kind: Class

Model Exponential Moving Average.

Keeps a moving average of everything in the model.state_dict (parameters and buffers).

###### __init__(self, model: pl.LightningModule, decay: float = 0.9999, use_dynamic_decay: bool = True, decay_tau: float = 2000)

Kind: Method

Constructs `ModelEma`.

@type model: L{pl.LightningModule}
@param model: Pytorch Lightning module.
@type decay: float
@param decay: Decay rate for the moving average.
@type use_dynamic_decay: bool
@param use_dynamic_decay: Use dynamic decay rate.
@type decay_tau: float
@param decay_tau: Decay tau for the moving average.

###### state_dict_ema

Kind: Instance Variable

###### updates

Kind: Instance Variable

###### decay

Kind: Instance Variable

###### use_dynamic_decay

Kind: Instance Variable

###### decay_tau

Kind: Instance Variable

###### update(self, model: pl.LightningModule)

Kind: Method

Update the stored parameters using a moving average.

Source: U{<https://github.com/huggingface/pytorch-image-models/blob/main/timm/utils/model_ema.py>}

@license: U{Apache License 2.0<https://github.com/huggingface/pytorch-image-models/tree/main?tab=Apache-2.0-1-ov-file#readme>}

@type model: L{pl.LightningModule}
@param model: Pytorch Lightning module.

##### export_on_train_end

Kind: Module

##### fail_on_no_train_batches

Kind: Module

##### gpu_stats_monitor

Kind: Module

GPU Stats Monitor.

Monitor and logs GPU stats during training.

Copyright The PyTorch Lightning team.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.

##### graceful_interrupt

Kind: Module

##### gradcam_visualizer

Kind: Module

###### luxonis_train.callbacks.gradcam_visualizer.PLModuleWrapper(lightning.pytorch.LightningModule)

Kind: Class

###### __init__(self, pl_module: lxt.LuxonisLightningModule, task: str)

Kind: Method

Constructs `ModelWrapper`.

@type pl_module: LuxonisLightningModule
@param pl_module: The model to be wrapped.
@type task: str
@param task: The type of task (e.g., segmentation, detection,
classification, keypoint_detection).

###### pl_module

Kind: Instance Variable

###### task

Kind: Instance Variable

###### forward(self, inputs: Tensor, args, kwargs) -> Tensor: Tensor

Kind: Method

Forward pass through the model, returning the output based on
the task type.

@type inputs: Tensor
@param inputs: Input tensor for the model.
@type args: Any
@param args: Additional positional arguments.
@type kwargs: Any
@param kwargs: Additional keyword arguments.
@rtype: Tensor
@return: The processed output based on the task type.

##### luxonis_model_summary

Kind: Module

##### luxonis_progress_bar

Kind: Module

##### metadata_logger

Kind: Module

##### needs_checkpoint

Kind: Module

###### luxonis_train.callbacks.needs_checkpoint.NeedsCheckpoint(lightning.pytorch.Callback)

Kind: Class

###### __init__(self, preferred_checkpoint: Literal [ ' metric ' , ' loss ' ] = 'metric', kwargs)

Kind: Method

###### preferred_checkpoint

Kind: Instance Variable

###### get_checkpoint(self, pl_module: lxt.LuxonisLightningModule) -> str|None: str|None

Kind: Method

##### test_on_train_end

Kind: Module

##### training_manager

Kind: Module

##### training_progress_callback

Kind: Module

##### upload_checkpoint

Kind: Module

##### luxonis_train.callbacks.ArchiveOnTrainEnd(luxonis_train.callbacks.needs_checkpoint.NeedsCheckpoint)

Kind: Class

###### on_train_end(self, _: pl.Trainer, pl_module: lxt.LuxonisLightningModule)

Kind: Method

Archives the model on train end.

@type trainer: L{pl.Trainer}
@param trainer: Pytorch Lightning trainer.
@type pl_module: L{pl.LightningModule}
@param pl_module: Pytorch Lightning module.

##### luxonis_train.callbacks.ConvertOnTrainEnd(luxonis_train.callbacks.needs_checkpoint.NeedsCheckpoint)

Kind: Class

Callback that exports, archives, and converts the model on train end.

###### on_train_end(self, trainer: pl.Trainer, pl_module: lxt.LuxonisLightningModule)

Kind: Method

Converts the model on train end.

@type trainer: L{pl.Trainer}
@param trainer: Pytorch Lightning trainer.
@type pl_module: L{pl.LightningModule}
@param pl_module: Pytorch Lightning module.

##### luxonis_train.callbacks.EMACallback(lightning.pytorch.Callback)

Kind: Class

Callback that updates the stored parameters using a moving average.

###### __init__(self, decay: float = 0.5, use_dynamic_decay: bool = True, decay_tau: float = 2000)

Kind: Method

Constructs `EMACallback`.

@type decay: float
@param decay: Decay rate for the moving average.
@type use_dynamic_decay: bool
@param use_dynamic_decay: Use dynamic decay rate. If True, the
decay rate will be updated based on the number of updates.
@type decay_tau: float
@param decay_tau: Decay tau for the moving average.

###### decay

Kind: Instance Variable

###### use_dynamic_decay

Kind: Instance Variable

###### decay_tau

Kind: Instance Variable

###### loaded_ema_state_dict

Kind: Instance Variable

###### loaded_ema_updates

Kind: Instance Variable

###### collected_state_dict

Kind: Instance Variable

###### ema

Kind: Property

###### on_fit_start(self, trainer: pl.Trainer, pl_module: pl.LightningModule)

Kind: Method

Initialize `ModelEma` to keep a copy of the moving average of
the weights.

@type trainer: L{pl.Trainer}
@param trainer: Pytorch Lightning trainer.
@type pl_module: L{pl.LightningModule}
@param pl_module: Pytorch Lightning module.

###### on_train_batch_end(self, trainer: pl.Trainer, pl_module: pl.LightningModule, outputs: STEP_OUTPUT, batch: Any, batch_idx:
int)

Kind: Method

Update the stored parameters using a moving average.

@type trainer: L{pl.Trainer}
@param trainer: Pytorch Lightning trainer.
@type pl_module: L{pl.LightningModule}
@param pl_module: Pytorch Lightning module.
@type outputs: Any
@param outputs: Outputs from the training step.
@type batch: Any
@param batch: Batch data.
@type batch_idx: int
@param batch_idx: Batch index.

###### on_validation_epoch_start(self, trainer: pl.Trainer, pl_module: pl.LightningModule)

Kind: Method

Swap the model's weights to the EMA weights at the start of
validation.

@type trainer: L{pl.Trainer}
@param trainer: Pytorch Lightning trainer.
@type pl_module: L{pl.LightningModule}
@param pl_module: Pytorch Lightning module.

###### on_validation_end(self, trainer: pl.Trainer, pl_module: pl.LightningModule)

Kind: Method

Restore the original model weights after validation.

@type trainer: L{pl.Trainer}
@param trainer: Pytorch Lightning trainer.
@type pl_module: L{pl.LightningModule}
@param pl_module: Pytorch Lightning module.

###### on_test_epoch_start(self, trainer: pl.Trainer, pl_module: pl.LightningModule)

Kind: Method

Swap the model's weights to the EMA weights at the start of
testing.

@type trainer: L{pl.Trainer}
@param trainer: Pytorch Lightning trainer.
@type pl_module: L{pl.LightningModule}
@param pl_module: Pytorch Lightning module.

###### on_test_end(self, trainer: pl.Trainer, pl_module: pl.LightningModule)

Kind: Method

Restore the original model weights after testing.

@type trainer: L{pl.Trainer}
@param trainer: Pytorch Lightning trainer.
@type pl_module: L{pl.LightningModule}
@param pl_module: Pytorch Lightning module.

###### on_train_end(self, trainer: pl.Trainer, pl_module: pl.LightningModule)

Kind: Method

Replace the model's weights with the EMA weights at the end
of training.

This final update ensures that the trained model uses the EMA
weights.
@type trainer: L{pl.Trainer}
@param trainer: Pytorch Lightning trainer.
@type pl_module: L{pl.LightningModule}
@param pl_module: Pytorch Lightning module.

###### on_save_checkpoint(self, trainer: pl.Trainer, pl_module: pl.LightningModule, checkpoint: dict)

Kind: Method

Save the EMA state dictionary into the checkpoint.

@type trainer: L{pl.Trainer}
@param trainer: Pytorch Lightning trainer.
@type pl_module: L{pl.LightningModule}
@param pl_module: Pytorch Lightning module.
@type checkpoint: dict
@param checkpoint: Pytorch Lightning checkpoint.

###### state_dict(self) -> dict[str, Any]: dict[str, Any]

Kind: Method

###### load_state_dict(self, state_dict: dict [ str , Any ])

Kind: Method

###### on_load_checkpoint(self, trainer: pl.Trainer, pl_module: pl.LightningModule, callback_state: dict)

Kind: Method

Load the EMA state dictionary from the checkpoint.

@type callback_state: dict
@param callback_state: Pytorch Lightning callback state.

##### luxonis_train.callbacks.ExportOnTrainEnd(luxonis_train.callbacks.needs_checkpoint.NeedsCheckpoint)

Kind: Class

###### on_train_end(self, _: pl.Trainer, pl_module: lxt.LuxonisLightningModule)

Kind: Method

Exports the model on train end.

@type trainer: L{pl.Trainer}
@param trainer: Pytorch Lightning trainer.
@type pl_module: L{pl.LightningModule}
@param pl_module: Pytorch Lightning module.

##### luxonis_train.callbacks.FailOnNoTrainBatches(lightning.pytorch.Callback)

Kind: Class

Handles cases where number of training batches is 0 either due to too large effective batch size or skipping the last batch.

###### on_fit_start(self, trainer: pl.Trainer, pl_module: pl.LightningModule)

Kind: Method

##### luxonis_train.callbacks.GPUStatsMonitor(lightning.pytorch.Callback)

Kind: Class

###### __init__(self, memory_utilization: bool = True, gpu_utilization: bool = True, intra_step_time: bool = False,
inter_step_time: bool = False, fan_speed: bool = False, temperature: bool = False)

Kind: Method

Automatically monitors and logs GPU stats during training
stage. C{GPUStatsMonitor} is a callback and in order to use it
you need to assign a logger in the C{Trainer}.

GPU stats are mainly based on C{nvidia-smi --query-gpu} command. The description of the queries is as follows:

- C{fan.speed} - The fan speed value is the percent of maximum speed that the device's fan is currently
intended to run at. It ranges from 0 to 100 %. Note: The reported speed is the intended fan speed.
If the fan is physically blocked and unable to spin, this output will not match the actual fan speed.
Many parts do not report fan speeds because they rely on cooling via fans in the surrounding enclosure.
- C{memory.used} - Total memory allocated by active contexts.
- C{memory.free} - Total free memory.
- C{utilization.gpu} - Percent of time over the past sample period during which one or more kernels was
executing on the GPU. The sample period may be between 1 second and 1/6 second depending on the product.
- C{utilization.memory} - Percent of time over the past sample period during which global (device) memory was
being read or written. The sample period may be between 1 second and 1/6 second depending on the product.
- C{temperature.gpu} - Core GPU temperature, in degrees C.
- C{temperature.memory} - HBM memory temperature, in degrees C.

@type memory_utilization: bool
@param memory_utilization: Set to C{True} to monitor used, free and percentage of memory utilization at the start and end of each
step. Defaults to C{True}.
@type gpu_utilization: bool
@param gpu_utilization: Set to C{True} to monitor percentage of GPU utilization at the start and end of each step. Defaults to
C{True}.
@type intra_step_time: bool
@param intra_step_time: Set to C{True} to monitor the time of each step. Defaults to {False}.
@type inter_step_time: bool
@param inter_step_time: Set to C{True} to monitor the time between the end of one step and the start of the next step. Defaults to
C{False}.
@type fan_speed: bool
@param fan_speed: Set to C{True} to monitor percentage of fan speed. Defaults to C{False}.
@type temperature: bool
@param temperature: Set to C{True} to monitor the memory and gpu temperature in degree Celsius. Defaults to C{False}.
@raises MisconfigurationException: If NVIDIA driver is not installed, not running on GPUs, or C{Trainer} has no logger.

###### is_available() -> bool: bool

Kind: Static Method

###### setup(self, trainer: pl.Trainer, pl_module: pl.LightningModule, stage: str | None = None)

Kind: Method

###### on_train_epoch_start(self, trainer: pl.Trainer, pl_module: pl.LightningModule)

Kind: Method

###### on_train_batch_start(self, trainer: pl.Trainer, pl_module: pl.LightningModule, batch: Any, batch_idx: int)

Kind: Method

###### on_train_batch_end(self, trainer: pl.Trainer, pl_module: pl.LightningModule, outputs: STEP_OUTPUT, batch: Any, batch_idx:
int)

Kind: Method

##### luxonis_train.callbacks.GracefulInterruptCallback(lightning.pytorch.Callback)

Kind: Class

Handles SIGINT/SIGTERM.

Behavior:

First interrupt: save checkpoint, stop training, skip all train-end callbacks.

Second interrupt: immediate exit, skip saving resume.ckpt.

###### __init__(self, save_dir: Path, tracker: LuxonisTrackerPL | None = None)

Kind: Method

###### save_dir

Kind: Instance Variable

###### tracker

Kind: Instance Variable

###### setup(self, trainer: pl.Trainer, pl_module: lxt.LuxonisLightningModule, stage: str | None = None)

Kind: Method

###### on_train_end(self, trainer: pl.Trainer, pl_module: lxt.LuxonisLightningModule)

Kind: Method

Prevent all other train-end callbacks (TestOnTrainEnd,
ExportOnTrainEnd, etc) from running if the training terminated
due to interrupt.

##### luxonis_train.callbacks.GradCamCallback(lightning.pytorch.Callback)

Kind: Class

Callback to visualize gradients using Grad-CAM (experimental).

Works only during validation.

###### __init__(self, target_layer: int, class_idx: int = 0, log_n_batches: int = 1, task: str = 'classification')

Kind: Method

Constructs `GradCamCallback`.

@type target_layer: int
@param target_layer: Layer to visualize gradients.
@type class_idx: int | None
@param class_idx: Index of the class for visualization. Defaults
to None.
@type log_n_batches: int
@param log_n_batches: Number of batches to log. Defaults to 1.
@type task: str
@param task: The type of task. Defaults to "classification".

###### target_layer

Kind: Instance Variable

###### class_idx

Kind: Instance Variable

###### log_n_batches

Kind: Instance Variable

###### task

Kind: Instance Variable

###### setup(self, trainer: pl.Trainer, pl_module: lxt.LuxonisLightningModule, stage: str)

Kind: Method

Initializes the model wrapper.

@type trainer: pl.Trainer
@param trainer: The PyTorch Lightning trainer.
@type pl_module: LuxonisLightningModule
@param pl_module: The LuxonisLightningModule.
@type stage: str
@param stage: The stage of the training loop.

###### pl_module

Kind: Instance Variable

###### on_validation_batch_end(self, trainer: pl.Trainer, pl_module: lxt.LuxonisLightningModule, outputs: STEP_OUTPUT, batch:
tuple [ dict [ str , Tensor ] , Packet [ Tensor ] ], batch_idx: int)

Kind: Method

At the end of first n batches, visualize the gradients using
Grad-CAM.

@type trainer: pl.Trainer
@param trainer: The PyTorch Lightning trainer.
@type pl_module: LuxonisLightningModule
@param pl_module: The PyTorch Lightning module.
@type outputs: STEP_OUTPUT
@param outputs: The output of the model.
@type batch: Any
@param batch: The input batch.
@type batch_idx: int
@param batch_idx: The index of the batch.

###### visualize_gradients(self, trainer: pl.Trainer, pl_module: lxt.LuxonisLightningModule, images: Tensor, batch_idx: int)

Kind: Method

Visualizes the gradients using Grad-CAM.

@type trainer: pl.Trainer
@param trainer: The PyTorch Lightning trainer.
@type pl_module: pl.LightningModule
@param pl_module: The PyTorch Lightning module.
@type images: Tensor
@param images: The input images.
@type batch_idx: int
@param batch_idx: The index of the batch.

###### gradcam

Kind: Instance Variable

##### luxonis_train.callbacks.LuxonisModelSummary(lightning.pytorch.callbacks.RichModelSummary)

Kind: Class

###### __init__(self, rich: bool = True, kwargs)

Kind: Method

###### rich

Kind: Instance Variable

###### summarize(self, args, kwargs)

Kind: Method

##### luxonis_train.callbacks.BaseLuxonisProgressBar(abc.ABC, lightning.pytorch.callbacks.ProgressBar)

Kind: Class

###### get_metrics(self, trainer: pl.Trainer, pl_module: lxt.LuxonisLightningModule) -> dict[str, (int|str|float|dict[str,
float])]: dict[str, (int|str|float|dict[str, float])]

Kind: Method

###### print_results(self, stage: str, loss: float, metrics: Mapping [ str , Mapping [ str , ( int | str | float ) ] ], matrices:
Mapping [ str , Mapping [ str , Mapping [ str , Any ] ] ])

Kind: Method

Prints results to the console.

This includes the stage name, loss value, and tables with
metrics.

@type stage: str
@param stage: Stage name.
@type loss: float
@param loss: Loss value.
@type metrics: Mapping[str, Mapping[str, int | str | float]]
@param metrics: Metrics in format {table_name: table}.
@type matrices: Mapping[str, Mapping[str, Mapping[str, Any]]]
@param matrices: Matrices in format {table_name: {name:
matrix}}.

###### format_matrix_for_printing(self, node: Any, name: str, value: Tensor) -> dict[str, Any]: dict[str, Any]

Kind: Method

##### luxonis_train.callbacks.LuxonisRichProgressBar(lightning.pytorch.callbacks.RichProgressBar,
luxonis_train.callbacks.BaseLuxonisProgressBar)

Kind: Class

Custom rich text progress bar based on RichProgressBar from Pytorch Lightning.

###### __init__(self)

Kind: Method

###### console

Kind: Property

###### print_results(self, stage: str, loss: float, metrics: Mapping [ str , Mapping [ str , ( int | str | float ) ] ], matrices:
Mapping [ str , Mapping [ str , Mapping [ str , Any ] ] ])

Kind: Method

###### on_train_epoch_start(self, trainer: pl.Trainer, pl_module: lxt.LuxonisLightningModule)

Kind: Method

###### on_train_epoch_end(self, trainer: pl.Trainer, pl_module: lxt.LuxonisLightningModule)

Kind: Method

##### luxonis_train.callbacks.LuxonisTQDMProgressBar(lightning.pytorch.callbacks.TQDMProgressBar,
luxonis_train.callbacks.BaseLuxonisProgressBar)

Kind: Class

Custom text progress bar based on TQDMProgressBar from Pytorch Lightning.

###### __init__(self)

Kind: Method

###### print_results(self, stage: str, loss: float, metrics: Mapping [ str , Mapping [ str , ( int | str | float ) ] ], matrices:
Mapping [ str , Mapping [ str , Mapping [ str , Any ] ] ])

Kind: Method

###### on_train_epoch_start(self, trainer: pl.Trainer, pl_module: lxt.LuxonisLightningModule)

Kind: Method

###### on_train_epoch_end(self, trainer: pl.Trainer, pl_module: lxt.LuxonisLightningModule)

Kind: Method

##### luxonis_train.callbacks.MetadataLogger(lightning.pytorch.Callback)

Kind: Class

###### __init__(self, hyperparams: list [ str ])

Kind: Method

Callback that logs training metadata.

Metadata include all defined hyperparameters together with git
hashes of luxonis-ml and luxonis-train packages. Also stores
this information locally.

@type hyperparams: list[str]
@param hyperparams: List of hyperparameters to log.

###### hyperparams

Kind: Instance Variable

###### on_fit_start(self, _: pl.Trainer, pl_module: lxt.LuxonisLightningModule)

Kind: Method

##### luxonis_train.callbacks.TestOnTrainEnd(luxonis_train.callbacks.needs_checkpoint.NeedsCheckpoint)

Kind: Class

###### __init__(self, view: View = 'test')

Kind: Method

Callback to perform a test run at the end of the training.

@type view: Literal["train", "val", "test"]
@param view: The view to use for testing. Defaults to "test".

###### view

Kind: Instance Variable

###### on_train_end(self, trainer: pl.Trainer, pl_module: lxt.LuxonisLightningModule)

Kind: Method

##### luxonis_train.callbacks.TrainingManager(lightning.pytorch.callbacks.BaseFinetuning)

Kind: Class

###### freeze_before_training(self, pl_module: lxt.LuxonisLightningModule)

Kind: Method

###### finetune_function(self, pl_module: lxt.LuxonisLightningModule, epoch: int, optimizer: Optimizer)

Kind: Method

###### on_after_backward(self, trainer: pl.Trainer, pl_module: lxt.LuxonisLightningModule)

Kind: Method

PyTorch Lightning hook that is called after the backward
pass.

@type trainer: pl.Trainer
@param trainer: The trainer object.
@type pl_module: pl.LightningModule
@param pl_module: The pl_module object.

##### luxonis_train.callbacks.TrainingProgressCallback(lightning.pytorch.Callback)

Kind: Class

Publish training progress metrics.

Metrics published:

train/epoch_progress_percent: Percentage of current epoch completed

train/epoch_duration_sec: Time elapsed so far in current epoch (updated per batch)

train/epoch_completion_sec: Total duration of completed training epoch in seconds

val/epoch_completion_sec: Total duration of completed validation epoch in seconds

###### __init__(self, log_every_n_batches: int = 1)

Kind: Method

@type log_every_n_batches: int
@param log_every_n_batches: How often to log progress metrics
(every N batches). Can be set to higher to prevent logging
in real-time if there is too much logging overhead.
By default 1 means real-time.

###### log_every_n_batches

Kind: Instance Variable

###### on_train_epoch_start(self, trainer: pl.Trainer, pl_module: lxt.LuxonisLightningModule)

Kind: Method

###### on_train_batch_end(self, trainer: pl.Trainer, pl_module: lxt.LuxonisLightningModule, outputs: STEP_OUTPUT, batch: Any,
batch_idx: int)

Kind: Method

###### on_train_epoch_end(self, trainer: pl.Trainer, pl_module: lxt.LuxonisLightningModule)

Kind: Method

###### on_validation_epoch_start(self, trainer: pl.Trainer, pl_module: lxt.LuxonisLightningModule)

Kind: Method

###### on_validation_epoch_end(self, trainer: pl.Trainer, pl_module: lxt.LuxonisLightningModule)

Kind: Method

##### luxonis_train.callbacks.UploadCheckpoint(lightning.pytorch.Callback)

Kind: Class

Callback that uploads best checkpoint based on the validation loss.

###### __init__(self)

Kind: Method

Constructs `UploadCheckpoint`.

@type upload_directory: str
@param upload_directory: Path used as upload directory

###### last_best_checkpoints

Kind: Instance Variable

###### on_save_checkpoint(self, trainer: pl.Trainer, module: lxt.LuxonisLightningModule, checkpoint: dict [ str , Any ])

Kind: Method

#### config

Kind: Package

##### config

Kind: Module

###### luxonis_train.config.config.ImageSize(typing.NamedTuple)

Kind: Class

###### height: int

Kind: Class Variable

###### width: int

Kind: Class Variable

###### luxonis_train.config.config.FreezingConfig(luxonis_ml.typing.BaseModelExtraForbid)

Kind: Class

###### active: bool

Kind: Class Variable

###### unfreeze_after: NonNegativeInt|NonNegativeFloat|None

Kind: Class Variable

###### lr_after_unfreeze: NonNegativeFloat|None

Kind: Class Variable

###### luxonis_train.config.config.PredefinedModelConfig(luxonis_ml.typing.ConfigItem)

Kind: Class

###### variant: str|Literal['default', 'none']|None

Kind: Class Variable

###### include_losses: bool

Kind: Class Variable

###### include_metrics: bool

Kind: Class Variable

###### include_visualizers: bool

Kind: Class Variable

###### luxonis_train.config.config.ModelConfig(luxonis_ml.typing.BaseModelExtraForbid)

Kind: Class

###### name: str

Kind: Class Variable

###### predefined_model: Annotated[(PredefinedModelConfig|None), Field(exclude=True)]

Kind: Class Variable

###### weights: Annotated[(FilePath|None), Field(exclude=True)]

Kind: Class Variable

###### nodes: list[NodeConfig]

Kind: Class Variable

###### outputs

Kind: Instance Variable

###### validate_nodes

Kind: Class Method

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

Kind: Method

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

Kind: Method

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

Kind: Method

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

Kind: Method

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

Kind: Method

###### head_nodes

Kind: Property

###### luxonis_train.config.config.TrackerConfig(luxonis_ml.typing.BaseModelExtraForbid)

Kind: Class

###### project_name: str|None

Kind: Class Variable

###### project_id: str|None

Kind: Class Variable

###### run_name: str|None

Kind: Class Variable

###### run_id: str|None

Kind: Class Variable

###### save_directory: Annotated[Path, Field(exclude=True)]

Kind: Class Variable

###### is_tensorboard: bool

Kind: Class Variable

###### is_wandb: bool

Kind: Class Variable

###### wandb_entity: str|None

Kind: Class Variable

###### is_mlflow: bool

Kind: Class Variable

###### luxonis_train.config.config.LoaderConfig(luxonis_ml.typing.ConfigItem)

Kind: Class

###### name: str

Kind: Class Variable

###### image_source: str

Kind: Class Variable

###### train_view: list[str]

Kind: Class Variable

###### val_view: list[str]

Kind: Class Variable

###### test_view: list[str]

Kind: Class Variable

###### serialize_params(self, info: SerializationInfo) -> Any: Any

Kind: Method

###### serialize_name(self, info: SerializationInfo) -> str: str

Kind: Method

###### validate_view

Kind: Class Method

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

Kind: Method

###### luxonis_train.config.config.NormalizeAugmentationConfig(luxonis_ml.typing.BaseModelExtraForbid)

Kind: Class

###### active: bool

Kind: Class Variable

###### params: Params

Kind: Class Variable

###### luxonis_train.config.config.AugmentationConfig(luxonis_ml.typing.ConfigItem)

Kind: Class

###### active: bool

Kind: Class Variable

###### use_for_resizing: bool

Kind: Class Variable

###### apply_on_stages: list[Literal['train', 'val', 'test']]

Kind: Class Variable

###### luxonis_train.config.config.PreprocessingConfig(luxonis_ml.typing.BaseModelExtraForbid)

Kind: Class

###### train_image_size: Annotated[ImageSize, Field(min_length=2, max_length=2)]

Kind: Class Variable

###### keep_aspect_ratio: bool

Kind: Class Variable

###### color_space: Literal['RGB', 'BGR', 'GRAY']

Kind: Class Variable

###### normalize: NormalizeAugmentationConfig

Kind: Class Variable

###### augmentations: list[AugmentationConfig]

Kind: Class Variable

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

Kind: Method

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

Kind: Method

###### serialize_model(self, info: SerializationInfo) -> Params: Params

Kind: Method

###### get_active_augmentations(self) -> list[AugmentationConfig]: list[AugmentationConfig]

Kind: Method

Returns list of augmentations that are active.

@rtype: list[AugmentationConfig]
@return: Filtered list of active augmentation configs

###### luxonis_train.config.config.CallbackConfig(luxonis_ml.typing.ConfigItem)

Kind: Class

###### active: bool

Kind: Class Variable

###### luxonis_train.config.config.OnnxExportConfig(luxonis_ml.typing.BaseModelExtraForbid)

Kind: Class

###### opset_version: PositiveInt

Kind: Class Variable

###### dynamic_axes: Params|None

Kind: Class Variable

###### disable_onnx_simplification: bool

Kind: Class Variable

###### unique_onnx_initializers: bool

Kind: Class Variable

###### luxonis_train.config.config.BlobconverterExportConfig(luxonis_ml.typing.BaseModelExtraForbid)

Kind: Class

###### active: bool

Kind: Class Variable

###### shaves: int

Kind: Class Variable

###### version: Literal['2021.2', '2021.3', '2021.4', '2022.1', '2022.3_RVC3']

Kind: Class Variable

###### luxonis_train.config.config.HubAIExportConfig(luxonis_ml.typing.BaseModelExtraForbid)

Kind: Class

###### active: bool

Kind: Class Variable

###### platform: Literal['rvc2', 'rvc3', 'rvc4', 'hailo']|None

Kind: Class Variable

###### params: Params

Kind: Class Variable

###### delete_remote_model: bool

Kind: Class Variable

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

Kind: Method

###### luxonis_train.config.config.ArchiveConfig(luxonis_ml.typing.BaseModelExtraForbid)

Kind: Class

###### name: str|None

Kind: Class Variable

###### upload_to_run: bool

Kind: Class Variable

###### upload_url: str|None

Kind: Class Variable

###### luxonis_train.config.config.StorageConfig(luxonis_ml.typing.BaseModelExtraForbid)

Kind: Class

###### active: bool

Kind: Class Variable

###### backend: str

Kind: Class Variable

###### username: str|None

Kind: Class Variable

###### password: SecretStr|None

Kind: Class Variable

###### host: str|None

Kind: Class Variable

###### port: PositiveInt|None

Kind: Class Variable

###### database: str|None

Kind: Class Variable

###### luxonis_train.config.config.TunerConfig(luxonis_ml.typing.BaseModelExtraForbid)

Kind: Class

###### study_name: str

Kind: Class Variable

###### continue_existing_study: bool

Kind: Class Variable

###### use_pruner: bool

Kind: Class Variable

###### n_trials: PositiveInt|None

Kind: Class Variable

###### timeout: PositiveInt|None

Kind: Class Variable

###### storage: StorageConfig

Kind: Class Variable

###### params: dict[str, list[(str|int|float|bool|list)]]

Kind: Class Variable

###### monitor: Literal['metric', 'loss']

Kind: Class Variable

##### predefined_models

Kind: Package

###### anomaly_detection_model

Kind: Module

###### base_predefined_model

Kind: Module

######
luxonis_train.config.predefined_models.base_predefined_model.SimplePredefinedModel(luxonis_train.config.BasePredefinedModel)

Kind: Class

###### __init__(self, backbone: str, backbone_variant: str | None = None, head: str, head_variant: str | None = None, neck: str |
None = None, neck_variant: str | None = None, loss: str, metrics: str | list [ str ] | None, main_metric: str | None = None,
visualizer: str | None = None, confusion_matrix_available: bool = False, backbone_params: Params | None = None, neck_params:
Params | None = None, use_neck: bool = True, head_params: Params | None = None, loss_params: Params | None = None, metrics_params:
Params | None = None, visualizer_params: Params | None = None, enable_confusion_matrix: bool = True, confusion_matrix_params:
Params | None = None, task_name: str | None = None, torchmetrics_task: Literal [ ' binary ' , ' multiclass ' , ' multilabel ' ] |
None = None, per_class_metrics: bool | None = None)

Kind: Method

###### nodes

Kind: Property

###### classification_model

Kind: Module

###### detection_fomo_model

Kind: Module

###### detection_model

Kind: Module

###### instance_segmentation_model

Kind: Module

###### keypoint_detection_model

Kind: Module

###### ocr_recognition_model

Kind: Module

###### AlphabetName: TypeAlias

Kind: Type Alias

###### segmentation_model

Kind: Module

######
luxonis_train.config.predefined_models.AnomalyDetectionModel(luxonis_train.config.predefined_models.base_predefined_model.SimplePredefinedModel)

Kind: Class

###### __init__(self, kwargs)

Kind: Method

###### get_variants() -> tuple[str, dict[str, Params]]: tuple[str, dict[str, Params]]

Kind: Static Method

######
luxonis_train.config.predefined_models.ClassificationModel(luxonis_train.config.predefined_models.base_predefined_model.SimplePredefinedModel)

Kind: Class

###### __init__(self, kwargs)

Kind: Method

###### get_variants() -> tuple[str, dict[str, Params]]: tuple[str, dict[str, Params]]

Kind: Static Method

######
luxonis_train.config.predefined_models.FOMOModel(luxonis_train.config.predefined_models.base_predefined_model.SimplePredefinedModel)

Kind: Class

###### __init__(self, kwargs)

Kind: Method

###### get_variants() -> tuple[str, dict[str, Params]]: tuple[str, dict[str, Params]]

Kind: Static Method

######
luxonis_train.config.predefined_models.DetectionModel(luxonis_train.config.predefined_models.base_predefined_model.SimplePredefinedModel)

Kind: Class

###### __init__(self, kwargs)

Kind: Method

###### get_variants() -> tuple[str, dict[str, Params]]: tuple[str, dict[str, Params]]

Kind: Static Method

######
luxonis_train.config.predefined_models.InstanceSegmentationModel(luxonis_train.config.predefined_models.base_predefined_model.SimplePredefinedModel)

Kind: Class

###### __init__(self, kwargs)

Kind: Method

###### get_variants() -> tuple[str, dict[str, Params]]: tuple[str, dict[str, Params]]

Kind: Static Method

######
luxonis_train.config.predefined_models.KeypointDetectionModel(luxonis_train.config.predefined_models.base_predefined_model.SimplePredefinedModel)

Kind: Class

###### __init__(self, kwargs)

Kind: Method

###### get_variants() -> tuple[str, dict[str, Params]]: tuple[str, dict[str, Params]]

Kind: Static Method

######
luxonis_train.config.predefined_models.OCRRecognitionModel(luxonis_train.config.predefined_models.base_predefined_model.SimplePredefinedModel)

Kind: Class

###### __init__(self, alphabet: list [ str ] | AlphabetName = 'english', max_text_len: int = 40, ignore_unknown: bool = True,
kwargs)

Kind: Method

###### get_variants() -> tuple[str, dict[str, Params]]: tuple[str, dict[str, Params]]

Kind: Static Method

######
luxonis_train.config.predefined_models.SegmentationModel(luxonis_train.config.predefined_models.base_predefined_model.SimplePredefinedModel)

Kind: Class

###### __init__(self, use_aux_head: bool = True, aux_head_params: Params | None = None, kwargs)

Kind: Method

###### get_variants() -> tuple[str, dict[str, Params]]: tuple[str, dict[str, Params]]

Kind: Static Method

###### nodes

Kind: Property

##### luxonis_train.config.AttachedModuleConfig(luxonis_ml.typing.ConfigItem)

Kind: Class

###### alias: str|None

Kind: Class Variable

###### identifier

Kind: Property

##### luxonis_train.config.Config(luxonis_ml.utils.LuxonisConfig)

Kind: Class

###### rich_logging: bool

Kind: Class Variable

###### model: ModelConfig

Kind: Class Variable

###### loader: LoaderConfig

Kind: Class Variable

###### tracker: TrackerConfig

Kind: Class Variable

###### trainer: TrainerConfig

Kind: Class Variable

###### exporter: ExportConfig

Kind: Class Variable

###### archiver: ArchiveConfig

Kind: Class Variable

###### tuner: TunerConfig

Kind: Class Variable

###### ENVIRON: Environ

Kind: Constant

###### model_dump(self, exclude: set [ str ] | None = None, kwargs) -> dict[str, Any]: dict[str, Any]

Kind: Method

###### model_dump_json(self, exclude: set [ str ] | None = None, kwargs) -> str: str

Kind: Method

###### check_environment

Kind: Class Method

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

Kind: Method

###### check_rich_logging

Kind: Class Method

###### get_config

Kind: Class Method

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

Kind: Method

Automatically populates config fields based on rules, with
warnings.

##### luxonis_train.config.ExportConfig(luxonis_train.config.config.ArchiveConfig)

Kind: Class

###### name: str|None

Kind: Class Variable

###### input_shape: list[int]|None

Kind: Class Variable

###### quantization_mode: Annotated[str, BeforeValidator(_validate_quantization_mode),
Field(validation_alias=AliasChoices(quantization_mode, data_type))]

Kind: Class Variable

###### reverse_input_channels: bool|None

Kind: Class Variable

###### scale_values: list[float]|None

Kind: Class Variable

###### mean_values: list[float]|None

Kind: Class Variable

###### onnx: OnnxExportConfig

Kind: Class Variable

###### blobconverter: BlobconverterExportConfig

Kind: Class Variable

###### hubai: HubAIExportConfig

Kind: Class Variable

###### check_values

Kind: Class Method

##### luxonis_train.config.LossModuleConfig(luxonis_train.config.AttachedModuleConfig)

Kind: Class

###### weight: NonNegativeFloat

Kind: Class Variable

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

Kind: Method

##### luxonis_train.config.MetricModuleConfig(luxonis_train.config.AttachedModuleConfig)

Kind: Class

###### is_main_metric: bool

Kind: Class Variable

##### luxonis_train.config.NodeConfig(luxonis_ml.typing.ConfigItem)

Kind: Class

###### alias: str|None

Kind: Class Variable

###### inputs: list[str]

Kind: Class Variable

###### input_sources: list[str]

Kind: Class Variable

###### freezing: FreezingConfig

Kind: Class Variable

###### remove_on_export: bool

Kind: Class Variable

###### task_name: str|None

Kind: Class Variable

###### metadata_task_override: str|dict[str, str]|None

Kind: Class Variable

###### variant: Annotated[str, BeforeValidator(str)]|Literal['default', 'none']|None

Kind: Class Variable

###### losses: list[LossModuleConfig]

Kind: Class Variable

###### metrics: list[MetricModuleConfig]

Kind: Class Variable

###### visualizers: list[AttachedModuleConfig]

Kind: Class Variable

###### identifier

Kind: Property

##### luxonis_train.config.TrainerConfig(luxonis_ml.typing.BaseModelExtraForbid)

Kind: Class

###### preprocessing: PreprocessingConfig

Kind: Class Variable

###### precision: Literal['16-mixed', '32']

Kind: Class Variable

###### accelerator: Literal['auto', 'cpu', 'gpu', 'tpu']

Kind: Class Variable

###### devices: int|list[int]|str

Kind: Class Variable

###### strategy: Literal['auto', 'ddp']

Kind: Class Variable

###### n_sanity_val_steps: int

Kind: Class Variable

###### profiler: Literal['simple', 'advanced']|None

Kind: Class Variable

###### matmul_precision: Literal['medium', 'high', 'highest']|None

Kind: Class Variable

###### seed: int|None

Kind: Class Variable

###### n_validation_batches: PositiveInt|Literal[(-1)]|None

Kind: Class Variable

###### deterministic

Kind: Instance Variable

###### smart_cfg_auto_populate: bool

Kind: Class Variable

###### batch_size: PositiveInt

Kind: Class Variable

###### accumulate_grad_batches: PositiveInt|None

Kind: Class Variable

###### gradient_clip_val: NonNegativeFloat|None

Kind: Class Variable

###### gradient_clip_algorithm: Literal['norm', 'value']|None

Kind: Class Variable

###### use_weighted_sampler: bool

Kind: Class Variable

###### epochs: PositiveInt

Kind: Class Variable

###### overfit_batches: NonNegativeInt

Kind: Class Variable

###### resume_training: bool

Kind: Class Variable

###### n_workers

Kind: Instance Variable

###### validation_interval

Kind: Instance Variable

###### run_validation_after_first_epoch: bool

Kind: Class Variable

###### n_log_images: NonNegativeInt

Kind: Class Variable

###### skip_last_batch: bool

Kind: Class Variable

###### pin_memory: bool

Kind: Class Variable

###### log_sub_metrics: bool

Kind: Class Variable

###### log_sub_losses: bool

Kind: Class Variable

###### save_top_k: Literal[(-1)]|NonNegativeInt

Kind: Class Variable

###### callbacks: list[CallbackConfig]

Kind: Class Variable

###### optimizer: ConfigItem

Kind: Class Variable

###### scheduler: ConfigItem

Kind: Class Variable

###### training_strategy: ConfigItem|None

Kind: Class Variable

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

Kind: Method

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

Kind: Method

Keys in the GradientAccumulationSheduler.params.scheduling
should be ints but yaml can sometime auto-convert them to
strings.

This converts them back to ints if possible.

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

Kind: Method

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

Kind: Method

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

Kind: Method

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

Kind: Method

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

Kind: Method

Reorder callbacks so that EMA is the first callback, since it
needs to be updated before other callbacks.

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

Kind: Method

##### luxonis_train.config.BasePredefinedModel(luxonis_train.variants.VariantBase)

Kind: Class

###### nodes

Kind: Property

###### get_variants() -> tuple[str, dict[str, Params]]: tuple[str, dict[str, Params]]

Kind: Static Method

Returns a name of the default varaint and a dictionary of
available model variants with their parameters.

The keys are the variant names, and the values are dictionaries
of parameters which can be used as C{**kwargs} for the
predefined model constructor.

@rtype: tuple[str, dict[str, Params]]
@return: A tuple containing the default variant name and a
dictionary of available variants with their parameters.

###### generate_nodes(self, include_losses: bool = True, include_metrics: bool = True, include_visualizers: bool = True) ->
list[NodeConfig]: list[NodeConfig]

Kind: Method

#### core

Kind: Package

##### core

Kind: Module

##### utils

Kind: Package

###### annotate_utils

Kind: Module

###### annotate_from_directory(model: lxt.LuxonisModel, img_paths: Iterable [ PathType ], dataset_name: str, bucket_storage:
Literal [ ' local ' , ' gcs ' ] = 'local', delete_local: bool = True, delete_remote: bool = True, team_id: str | None = None) ->
LuxonisDataset: LuxonisDataset

Kind: Function

Annotate images from a directory using the specified model and
create a LuxonisDataset.

@param model: The LuxonisModel to use for annotation.
@type model: lxt.LuxonisModel
@param img_paths: Iterable of image paths to annotate.
@type img_paths: Iterable[PathType]
@param dataset_name: Name of the dataset to create.
@type dataset_name: str
@param bucket_storage: Storage type for the dataset, either 'local'
or 'gcs'.
@type bucket_storage: Literal['local', 'gcs']
@param delete_local: Whether to delete local files after processing.
@type delete_local: bool
@param delete_remote: Whether to delete remote files after
processing.
@type delete_remote: bool
@param team_id: Optional team ID for the dataset.
@type team_id: str | None

###### annotated_dataset_generator(model: lxt.LuxonisModel, loader: torch_data.DataLoader) -> DatasetIterator: DatasetIterator

Kind: Function

Generator that yields annotations for images processed by the
model.

###### archive_utils

Kind: Module

###### luxonis_train.core.utils.archive_utils.ArchiveMetadataDict(typing.TypedDict)

Kind: Class

###### shape: list[int]

Kind: Class Variable

###### dtype: DataType

Kind: Class Variable

###### get_inputs(path: Path) -> dict[str, ArchiveMetadataDict]: dict[str, ArchiveMetadataDict]

Kind: Function

Get inputs of a model executable.

@type path: Path
@param path: Path to model executable file.

###### get_outputs(path: Path) -> dict[str, ArchiveMetadataDict]: dict[str, ArchiveMetadataDict]

Kind: Function

Get outputs of a model executable.

@type path: Path
@param path: Path to model executable file.

###### get_head_configs(lightning_module: LuxonisLightningModule, outputs: list [ dict ]) -> list[dict]: list[dict]

Kind: Function

Get model heads.

@type lightning_module: LuxonisLightningModule
@param lightning_module: Lightning module.
@type outputs: list[dict]
@param outputs: List of NN Archive outputs.
@rtype: list[dict]
@return: List of head configurations.

###### export_utils

Kind: Module

###### replace_weights(module: lxt.LuxonisLightningModule, weights: PathType | dict [ str , Any ] | None = None) -> Generator:
Generator

Kind: Function

###### try_onnx_simplify(onnx_path: PathType)

Kind: Function

###### get_preprocessing(cfg: PreprocessingConfig, log_label: str | None = None) -> tuple[(list[float]|None), (list[float]|None),
Literal['RGB', 'BGR', 'GRAY']]: tuple[(list[float]|None), (list[float]|None), Literal['RGB', 'BGR', 'GRAY']]

Kind: Function

###### blobconverter_export(cfg: ExportConfig, scale_values: list [ float ] | None, mean_values: list [ float ] | None,
reverse_channels: bool, export_path: PathType, onnx_path: PathType) -> Path: Path

Kind: Function

###### hubai_export(cfg: HubAIExportConfig, quantization_mode: str, archive_path: PathType, export_path: PathType, model_name:
str, dataset_name: str | None = None) -> Path: Path

Kind: Function

Convert an ONNX NNArchive to a platform-specific NNArchive using
HubAI SDK.

If a model with the given name already exists on HubAI, a new
variant will be created under that model. Otherwise, a new model
will be created.

@type cfg: HubAIExportConfig
@param cfg: HubAI export configuration containing platform and
params.
@type quantization_mode: str
@param quantization_mode: Quantization mode for model conversion.
@type archive_path: PathType
@param archive_path: Path to the ONNX NNArchive to convert.
@type export_path: PathType
@param export_path: Directory where the converted archive will be
saved.
@type model_name: str
@param model_name: Name for the model on HubAI.
@type dataset_name: str | None
@param dataset_name: Name of the dataset the model was trained on.
@rtype: Path
@return: Path to the converted platform-specific NNArchive.

###### make_initializers_unique(onnx_path: PathType)

Kind: Function

Each initializer that is used by multiple nodes gets duplicated
so each node has its own copy.

@type onnx_path: PathType
@param onnx_path: Path to the ONNX model file to modify.

###### infer_utils

Kind: Module

###### IMAGE_FORMATS: set[str]

Kind: Constant

###### VIDEO_FORMATS: set[str]

Kind: Constant

###### process_visualizations(visualizations: dict [ str , dict [ str , Tensor ] ]) -> dict[tuple[str, str], list[np.ndarray]]:
dict[tuple[str, str], list[np.ndarray]]

Kind: Function

Render or save visualizations.

###### prepare_and_infer_image(model: lxt.LuxonisModel, images: dict [ str , Tensor ]) -> LuxonisOutput: LuxonisOutput

Kind: Function

Prepares the image for inference and runs the model.

###### window_closed() -> bool: bool

Kind: Function

###### infer_from_video(model: lxt.LuxonisModel, video_path: PathType, save_dir: Path | None)

Kind: Function

Runs inference on individual frames from a video.

@type model: L{LuxonisModel}
@param model: The model to use for inference.
@type video_path: PathType
@param video_path: The path to the video.
@type save_dir: Path | None
@param save_dir: The directory to save the visualizations to.
@type show: bool
@param show: Whether to display the visualizations.

###### infer_from_loader(model: lxt.LuxonisModel, loader: torch_data.DataLoader, save_dir: PathType | None, img_paths: list [
PathType ] | None = None)

Kind: Function

Runs inference on images from the dataset.

@type model: L{LuxonisModel}
@param model: The model to use for inference.
@type loader: torch_data.DataLoader
@param loader: The loader to use for inference.
@type save_dir: PathType | None
@param save_dir: The directory to save the visualizations to.
@type img_paths: list[Path] | None
@param img_paths: The paths to the images.

###### create_loader_from_directory(img_paths: Iterable [ PathType ], model: lxt.LuxonisModel, add_path_annotation: bool = False,
batch_size: int | None = None) -> torch_data.DataLoader: torch_data.DataLoader

Kind: Function

Creates a DataLoader from a directory of images.

@type img_paths: Iterable[PathType]
@param img_paths: Iterable of paths to the images.
@type model: L{LuxonisModel}
@param model: The model to use for inference.
@type add_path_annotation: bool
@param add_path_annotation: Whether to add the image path as an
annotation in the dataset.
@type batch_size: int | None
@param batch_size: The batch size for the DataLoader. If None, uses
the model's default batch size.
@rtype: torch_data.DataLoader
@return: The DataLoader for the images.

###### infer_from_directory(model: lxt.LuxonisModel, img_paths: Iterable [ PathType ], save_dir: Path | None)

Kind: Function

Runs inference on individual images from a directory.

@type model: L{LuxonisModel}
@param model: The model to use for inference.
@type img_paths: Iterable[Path]
@param img_paths: Iterable of paths to the images.
@type save_dir: Path | None
@param save_dir: The directory to save the visualizations to.

###### infer_from_dataset(model: lxt.LuxonisModel, view: Literal [ ' train ' , ' val ' , ' test ' ], save_dir: PathType | None)

Kind: Function

Runs inference on images from the dataset.

@type model: L{LuxonisModel}
@param model: The model to use for inference.
@type view: Literal["train", "val", "test"]
@param view: The view of the dataset to use.
@type save_dir: PathType | None
@param save_dir: The directory to save the visualizations to.

###### train_utils

Kind: Module

###### create_trainer(cfg: TrainerConfig, kwargs: Any) -> pl.Trainer: pl.Trainer

Kind: Function

Creates Pytorch Lightning trainer.

@type cfg: Config
@param cfg: Configuration object.
@param kwargs: Additional arguments to pass to the trainer.
@rtype: pl.Trainer
@return: Pytorch Lightning trainer.

###### tune_utils

Kind: Module

###### get_trial_params(all_augs: list [ str ], params: dict [ str , Any ], trial: optuna.trial.Trial) -> dict[str, Any]:
dict[str, Any]

Kind: Function

Get trial parameters based on specified config.

###### rename_params_for_logging(params: dict, tuner_params: dict | None = None) -> dict: dict

Kind: Function

Rename parameters used for logging.

##### luxonis_train.core.LuxonisModel

Kind: Class

Common logic of the core components.

This class contains common logic of the core components (trainer, evaluator, exporter, etc.).

###### __init__(self, cfg: PathType | Params | Config | None, opts: Params | list [ str ] | tuple [ str , ... ] | None = None,
allow_empty_dataset: bool = False, weights: PathType | dict [ str , Any ] | None = None, dataset_metadata: DatasetMetadata | None
= None)

Kind: Method

Constructs a new Core instance.

Loads the config and initializes loaders, dataloaders, augmentations,
lightning components, etc.

@type cfg: str | dict[str, Any] | Config
@param cfg: Path to config file or config dict used to setup training.

@type opts: list[str] | tuple[str, ...] | dict[str, Any] | None
@param opts: Argument dict provided through command line, used for config overriding.

@type allow_empty_dataset: bool
@param allow_empty_dataset: If set to True, the model will be initialized even if the dataset is empty or cannot be created
This is useful either for debugging or for running commands that don't require a dataset (e.g. export with existing weights).
@type weights: str | None
@param weights: Path to the weights. If user specifies weights
in the config file, the weights provided here will take
precedence.

###### cfg

Kind: Instance Variable

###### allow_empty_dataset

Kind: Instance Variable

###### weights

Kind: Instance Variable

###### cfg_preprocessing

Kind: Instance Variable

###### tracker

Kind: Instance Variable

###### run_save_dir

Kind: Instance Variable

###### log_file

Kind: Instance Variable

###### error_message

Kind: Instance Variable

###### pl_trainer

Kind: Instance Variable

###### loaders

Kind: Instance Variable

###### pytorch_loaders

Kind: Instance Variable

###### dataset_metadata

Kind: Instance Variable

###### config_file

Kind: Instance Variable

###### input_shapes

Kind: Instance Variable

###### lightning_module

Kind: Instance Variable

###### save_checkpoint(self, path: PathType, weights_only: bool = False, storage_options: Any = None) -> Path: Path

Kind: Method

Saves a checkpoint of the model.

@type path: PathType
@param path: Path where checkpoint will be saved.
@type weights_only: bool | None
@param weights_only: If `True`, will only save the model weights.
@type storage_options: Any
@param storage_options: parameter for how to save to storage, passed to `CheckpointIO` plugin
@rtype: Path
@return: Path to the saved checkpoint.
@raises AttributeError: If the module is not attached to the trainer yet. This can happen if you try to save a checkpoint before
training / evaluating the model first.

###### get_checkpoint(self, weights_only: bool = False) -> dict[str, Any]: dict[str, Any]

Kind: Method

Gets the checkpoint of the model as a dictionary.

@type weights_only: bool
@param weights_only: If `True`, will only include the model weights in the checkpoint.
@rtype: dict[str, Any]
@return: Checkpoint of the model as a dictionary.
@raises AttributeError: If the module is not attached to the trainer yet. This can happen if you try to save a checkpoint before
training / evaluating the model first.

###### train(self, new_thread: bool = False, weights: PathType | None = None)

Kind: Method

Runs training.

@type new_thread: bool
@param new_thread: Runs training in new thread if set to True.
@type weights: str | None
@param weights: Path to the weights. If user specifies weights
in the config file, the weights provided here will take
precedence.

###### export(self, save_path: PathType | None = None, weights: PathType | dict [ str , Any ] | None = None,
ignore_missing_weights: bool = False, ckpt_only: bool = False) -> Path: Path

Kind: Method

Runs export.

@type save_path: PathType | None
@param save_path: Directory where to save all exported model files.
If not specified, files will be saved to the "export" directory
in the run save directory.
@type weights: PathType | None
@param weights: Path to the checkpoint from which to load weights.
If not specified, the value of `model.weights` from the
configuration file will be used. The current weights of the
model will be temporarily replaced with the weights from the
specified checkpoint.
@type ignore_missing_weights: bool
@param ignore_missing_weights: If set to True, the warning about
missing weights will be suppressed.
@type ckpt_only: bool
@param ckpt_only: If True, only the `.ckpt` file will be exported.
This is useful for updating the metadata in the checkpoint
file in case they changed (e.g. new configuration file,
architectural changes affecting the exection order etc.)

###### test(self, new_thread: bool = False, view: Literal [ ' train ' , ' val ' , ' test ' ] = 'test', weights: PathType | dict [
str , Any ] | None = None) -> Mapping[str, float]|None: Mapping[str, float]|None

Kind: Method

Runs testing.

@type new_thread: bool
@param new_thread: Runs testing in a new thread if set to True.
@type view: Literal["train", "test", "val"]
@param view: Which view to run the testing on. Defauls to "test".
@rtype: Mapping[str, float] | None
@return: If new_thread is False, returns a dictionary test
results.
@type weights: PathType | None
@param weights: Path to the checkpoint from which to load weights.
If not specified, the value of `model.weights` from the
configuration file will be used. The current weights of the
model will be temporarily replaced with the weights from the
specified checkpoint.

###### thread

Kind: Instance Variable

###### infer(self, view: Literal [ ' train ' , ' val ' , ' test ' ] = 'val', save_dir: PathType | None = None, source_path:
PathType | None = None, weights: PathType | dict [ str , Any ] | None = None)

Kind: Method

Runs inference.

@type view: str
@param view: Which split to run the inference on. Valid values
are: C{"train"}, C{"val"}, C{"test"}. Defaults to C{"val"}.
@type save_dir: PathType | None
@param save_dir: Directory where to save the visualizations. If
not specified, visualizations will be rendered on the
screen.
@type source_path: PathType | None
@param source_path: Path to the image file, video file or directory.
If None, defaults to using dataset images.
@type weights: PathType | None
@param weights: Path to the checkpoint from which to load weights.
If not specified, the value of `model.weights` from the
configuration file will be used. The current weights of the
model will be temporarily replaced with the weights from the
specified checkpoint.

###### annotate(self, dir_path: PathType, dataset_name: str, weights: PathType | dict [ str , Any ] | None = None, bucket_storage:
Literal [ ' local ' , ' gcs ' ] = 'local', delete_local: bool = True, delete_remote: bool = True, team_id: str | None = None) ->
LuxonisDataset: LuxonisDataset

Kind: Method

###### tune(self)

Kind: Method

Runs Optuna tuning of hyperparameters.

###### parent_tracker

Kind: Instance Variable

###### archive(self, path: PathType | None = None, weights: PathType | dict [ str , Any ] | None = None, save_dir: PathType | None
= None) -> Path: Path

Kind: Method

Generates an NN Archive out of a model executable.

@type path: PathType | None
@param path: Path to the model executable. If not specified, the
model will be exported first.
@type weights: PathType | None
@param weights: Path to the checkpoint from which to load weights.
If not specified, the value of `model.weights` from the
configuration file will be used. The current weights of the
model will be temporarily replaced with the weights from the
specified checkpoint.
@rtype: Path
@return: Path to the generated NN Archive.

###### convert(self, weights: PathType | dict [ str , Any ] | None = None, save_dir: PathType | None = None) -> tuple[Path,
dict[str, Path]]: tuple[Path, dict[str, Path]]

Kind: Method

Exports the model to ONNX, creates an NN Archive, and
converts to target platform format (RVC2/RVC3/RVC4).

This is a unified method that combines export, archive, and platform
conversion steps.

@type weights: PathType | None
@param weights: Path to the checkpoint from which to load weights.
If not specified, the value of `model.weights` from the
configuration file will be used.
@type save_dir: PathType | None
@param save_dir: Directory where the outputs will be saved.
If not specified, the default run save directory will be used.
@rtype: tuple[Path, dict[str, Path]]
@return: A tuple of:
1) Path to the generated ONNX-based NN Archive.
2) Mapping of additional conversion artifact names to their paths.

###### environ

Kind: Property

###### get_min_loss_checkpoint_path(self) -> str|None: str|None

Kind: Method

Return best checkpoint path with respect to minimal
validation loss.

@rtype: str
@return: Path to the best checkpoint with respect to minimal
validation loss

###### get_best_metric_checkpoint_path(self) -> str|None: str|None

Kind: Method

Return best checkpoint path with respect to best validation
metric.

@rtype: str
@return: Path to the best checkpoint with respect to best
validation metric

###### get_mlflow_logging_keys(self) -> dict[str, list[str]]: dict[str, list[str]]

Kind: Method

Returns a dictionary with two lists of keys:
1) "metrics" -> Keys expected to be logged as standard metrics
2) "artifacts" -> Keys expected to be logged as artifacts (e.g. confusion_matrix.json, visualizations)

###### resolve_weights(self, weights: PathType | dict [ str , Any ] | None) -> PathType|dict[str, Any]|None: PathType|dict[str,
Any]|None

Kind: Method

#### lightning

Kind: Package

##### luxonis_lightning

Kind: Module

##### luxonis_output

Kind: Module

##### utils

Kind: Module

###### luxonis_train.lightning.utils.MainMetric(typing.NamedTuple)

Kind: Class

###### node_name: str

Kind: Class Variable

###### metric_name: str

Kind: Class Variable

###### luxonis_train.lightning.utils.LossAccumulator(collections.defaultdict)

Kind: Class

###### __init__(self)

Kind: Method

###### counts

Kind: Instance Variable

###### update(self, losses: dict [ str , Tensor ])

Kind: Method

###### clear(self)

Kind: Method

###### luxonis_train.lightning.utils.NodeWrapper(torch.nn.Module)

Kind: Class

###### __init__(self, name: str, module: BaseNode, losses: dict [ str , BaseLoss ], metrics: dict [ str , BaseMetric ],
visualizers: dict [ str , BaseVisualizer ], unfreeze_after: int | None, lr_after_unfreeze: float | None, inputs: list [ str ] |
None = None)

Kind: Method

###### name

Kind: Instance Variable

###### module

Kind: Instance Variable

###### losses

Kind: Instance Variable

###### metrics

Kind: Instance Variable

###### visualizers

Kind: Instance Variable

###### unfreeze_after

Kind: Instance Variable

###### lr_after_unfreeze

Kind: Instance Variable

###### inputs

Kind: Instance Variable

###### task_name

Kind: Property

###### luxonis_train.lightning.utils.Nodes((dict[str, NodeWrapper] if TYPE_CHECKING else nn.ModuleDict))

Kind: Class

###### __init__(self, cfg: Config, dataset_metadata: DatasetMetadata, input_shapes: dict [ str , Size ])

Kind: Method

###### graph

Kind: Instance Variable

###### nodes

Kind: Instance Variable

###### main_metric

Kind: Instance Variable

###### loader_input_shapes

Kind: Instance Variable

###### formatted_name(self, node_name: str) -> str: str

Kind: Method

###### frozen_nodes(self) -> Iterator[tuple[str, BaseNode, int, (float|None)]]: Iterator[tuple[str, BaseNode, int, (float|None)]]

Kind: Method

###### traverse(self) -> Iterator[tuple[str, NodeWrapper, list[str], list[str]]]: Iterator[tuple[str, NodeWrapper, list[str],
list[str]]]

Kind: Method

###### compute_losses(cfg: Config, losses: dict [ str , dict [ str , ( Tensor | tuple [ Tensor , dict [ str , Tensor ] ] ) ] ],
device: torch.device) -> tuple[Tensor, dict[str, Tensor]]: tuple[Tensor, dict[str, Tensor]]

Kind: Function

Computes the final loss as a weighted sum of all the losses.

@type losses: dict[str, dict[str, Tensor | tuple[Tensor, dict[str,
Tensor]]]]
@param losses: Dictionary of computed losses. Each node can have
multiple losses attached. The first key identifies the node, the
second key identifies the specific loss. Values are either
single tensors or tuples of tensors and sub- losses.
@rtype: tuple[Tensor, dict[str, Tensor]]
@return: Tuple of final loss and dictionary of all losses for
logging. The dictionary is in a format of C{{loss_name:
loss_value}}.

###### build_training_strategy(cfg: Config, pl_module: pl.LightningModule) -> BaseTrainingStrategy|None: BaseTrainingStrategy|None

Kind: Function

###### build_optimizers(cfg: Config, parameters: Iterable [ nn.Parameter ], main_metric: tuple [ str , str ] | None, nodes: Nodes)
-> tuple[list[Optimizer], list[(LRScheduler|dict[str, Any])]]: tuple[list[Optimizer], list[(LRScheduler|dict[str, Any])]]

Kind: Function

Configures model optimizers and schedulers.

###### build_callbacks(cfg: Config, main_metric: tuple [ str , str ] | None, save_dir: Path, nodes: Nodes) -> list[pl.Callback]:
list[pl.Callback]

Kind: Function

Configures Pytorch Lightning callbacks.

###### postprocess_metrics(name: str, values: Any, log_sub_metrics: bool = True) -> dict[str, Tensor]: dict[str, Tensor]

Kind: Function

Convert metric computation result into a dictionary of values.

###### T

Kind: Type Variable

###### A

Kind: Type Variable

###### log_balanced_class_images(tracker: LuxonisTrackerPL, nodes: Nodes, visualizations: dict [ str , dict [ str , Tensor ] ],
labels: Labels, cls_task_keys: list [ str ], class_log_counts: list [ int ], n_logged_images: int, max_log_images: int, mode:
Literal [ ' test ' , ' val ' ], current_epoch: int) -> tuple[int, list[int], list[int]]: tuple[int, list[int], list[int]]

Kind: Function

Log images with balanced class distribution.

###### log_sequential_images(tracker: LuxonisTrackerPL, nodes: Nodes, visualizations: dict [ str , dict [ str , Tensor ] ],
n_logged_images: int, max_log_images: int, mode: Literal [ ' test ' , ' val ' ], current_epoch: int) -> int: int

Kind: Function

Log first N images sequentially.

###### compute_visualization_buffer(seq_buffer: list [ dict [ str , dict [ str , Tensor ] ] ], visualizations: dict [ str , dict [
str , Tensor ] ], logged_idxs: list [ int ], max_log_images: int) -> dict[str, dict[str, Tensor]]|None: dict[str, dict[str,
Tensor]]|None

Kind: Function

Build a buffer of leftover visualizations to fill up to
`max_log_images` frames.

@type seq_buffer: list[dict[str, dict[str, Tensor]]]
@param seq_buffer: Previously buffered visualizations; each item maps node names to
dicts of viz names to Tensors of shape [N, …].
@type visualizations: dict[str, dict[str, Tensor]]
@param visualizations: Current batch's visualizations with the same nested structure.
@type logged_idxs: list[int]
@param logged_idxs: List of batch indices already logged by the smart (class-balanced) logger.
@type max_log_images: int
@param max_log_images: Total number of images we aim to log per epoch.
@return: A dict `{ node_name: { viz_name: Tensor[...] } }` containing up to the remaining
number of images needed to reach `max_log_images`, excluding any indices in
`logged_idxs`. Returns `None` if the buffer is already full or no leftovers exist.

###### get_model_execution_order(model: lxt.LuxonisLightningModule) -> list[str]: list[str]

Kind: Function

Get the execution order of the model's nodes.

###### get_main_metric(cfg: Config) -> MainMetric|None: MainMetric|None

Kind: Function

###### check_tensor_device(x: Tensor | list [ Tensor ], device: torch.device) -> bool: bool

Kind: Function

Return whether a tensor (or every tensor in a sequence) resides
on a given device.

##### luxonis_train.lightning.LuxonisLightningModule(lightning.pytorch.LightningModule)

Kind: Class

Class representing the entire model.

This class keeps track of the model graph, nodes, and attached modules. The model topology is defined as an acyclic graph of
nodes. The graph is saved as a dictionary of predecessors.

###### save_dir

Kind: Instance Variable

Directory to save checkpoints and logs.

###### nodes

Kind: Instance Variable

Nodes of the model. Keys are node names, unique for each node.

###### graph

Kind: Instance Variable

Graph of the model in a format of a dictionary of predecessors. Keys are node names, values are inputs to the node (list of node
names). Nodes with no inputs are considered inputs of the whole model.

###### loss_weights

Kind: Instance Variable

Dictionary of loss weights. Keys are loss names, values are weights.

###### input_shapes

Kind: Instance Variable

Dictionary of input shapes. Keys are node names, values are lists of shapes (understood as shapes of the "feature" field in
Packet[Tensor]).

###### outputs

Kind: Instance Variable

List of output node names.

###### losses

Kind: Instance Variable

Nested dictionary of losses used in the model. Each node can have multiple losses attached. The first key identifies the node, the
second key identifies the specific loss.

###### visualizers

Kind: Instance Variable

Dictionary of visualizers to be used with the model.

###### metrics

Kind: Instance Variable

Dictionary of metrics to be used with the model.

###### dataset_metadata

Kind: Instance Variable

Metadata of the dataset.

###### main_metric

Kind: Instance Variable

Name of the main metric to be used for model checkpointing. If not set, the model with the best metric score won't be saved.

###### logger: LuxonisTrackerPL

Kind: Class Variable

###### __call__: Callable[..., LuxonisOutput]

Kind: Class Variable

###### __init__(self, cfg: Config, save_dir: PathType, input_shapes: dict [ str , Size ], dataset_metadata: DatasetMetadata | None
= None, _core: luxonis_train.core.LuxonisModel | None = None, kwargs)

Kind: Method

Constructs an instance of `LuxonisModel` from `Config`.

@type cfg: L{Config}
@param cfg: Config object.
@type save_dir: str
@param save_dir: Directory to save checkpoints.
@type input_shapes: dict[str, Size]
@param input_shapes: Dictionary of input shapes. Keys are input
names, values are shapes.
@type dataset_metadata: L{DatasetMetadata} | None
@param dataset_metadata: Dataset metadata.
@type kwargs: Any
@param kwargs: Additional arguments to pass to the
L{LightningModule} constructor.

###### cfg

Kind: Instance Variable

###### image_source

Kind: Instance Variable

###### training_strategy

Kind: Instance Variable

###### load_state_dict(self, state_dict: Mapping [ str , Tensor ], strict: bool = True) -> _IncompatibleKeys: _IncompatibleKeys

Kind: Method

Default behavior for load_state_dict, unless resume_training
is active.

In case resume_training is active, allow loading in a non-strict
manner to allow loss, visualizer and metric nodes to be absent.

###### progress_bar

Kind: Property

###### tracker

Kind: Property

###### core

Kind: Property

Returns the core model.

###### forward(self, inputs: dict [ str , Tensor ], labels: Labels | None = None, images: Tensor | None = None, compute_loss: bool
= True, compute_metrics: bool = False, compute_visualizations: bool = False) -> LuxonisOutput: LuxonisOutput

Kind: Method

Forward pass of the model.

Traverses the graph and step-by-step computes the outputs of
each node. Each next node is computed only when all of its
predecessors are computed. Once the outputs are not needed
anymore, they are removed from the memory.

@type inputs: L{Tensor}
@param inputs: Input tensor.
@type task_labels: L{TaskLabels} | None
@param task_labels: Labels dictionary. Defaults to C{None}.
@type images: L{Tensor} | None
@param images: Canvas tensor for visualizers. Defaults to
C{None}.
@type compute_loss: bool
@param compute_loss: Whether to compute losses. Defaults to
C{True}.
@type compute_metrics: bool
@param compute_metrics: Whether to update metrics. Defaults to
C{True}.
@type compute_visualizations: bool
@param compute_visualizations: Whether to compute
visualizations. Defaults to C{False}.
@rtype: L{LuxonisOutput}
@return: Output of the model.

###### set_export_mode(self, mode: bool)

Kind: Method

###### export_onnx(self, save_path: PathType, kwargs) -> Path: Path

Kind: Method

Exports the model to ONNX format.

@type save_path: str
@param save_path: Path where the exported model will be saved.
@type kwargs: Any
@param kwargs: Additional arguments for the L{torch.onnx.export}
method.
@rtype: Path
@return: Path to the exported model.

###### training_step(self, train_batch: tuple [ dict [ str , Tensor ] , Labels ]) -> Tensor: Tensor

Kind: Method

###### validation_step(self, val_batch: tuple [ dict [ str , Tensor ] , Labels ]) -> dict[str, Tensor]: dict[str, Tensor]

Kind: Method

###### test_step(self, test_batch: tuple [ dict [ str , Tensor ] , Labels ]) -> dict[str, Tensor]: dict[str, Tensor]

Kind: Method

###### predict_step(self, batch: tuple [ dict [ str , Tensor ] , Labels ]) -> LuxonisOutput: LuxonisOutput

Kind: Method

###### setup(self, stage: str)

Kind: Method

Temporarily make validation run after the first training
epoch if the config item `run_validation_after_first_epoch` is
set.

Lightning decides whether validation should run at epoch end from
the public trainer attribute `check_val_every_n_epoch`. When
`trainer.run_validation_after_first_epoch` is enabled, we want to
keep using Lightning's normal validation path, but also ensure
that epoch 1 gets validated even if the configured `validation_interval`
normally skips it.

`trainer.check_val_every_n_epoch` is temporarily overriden to `1` before fitting starts.
After that first real validation epoch
completes, `on_validation_epoch_end()` restores the original
interval so the rest of training follows the configured cadence.

This override is intentionally applied only when `run_validation_after_first_epoch=True`

###### on_train_epoch_start(self)

Kind: Method

###### on_train_epoch_end(self)

Kind: Method

###### on_validation_epoch_end(self)

Kind: Method

Restore the original validation interval after epoch 1
validation.

###### on_test_epoch_end(self)

Kind: Method

###### on_save_checkpoint(self, checkpoint: dict [ str , Any ])

Kind: Method

###### configure_callbacks(self) -> list[pl.Callback]: list[pl.Callback]

Kind: Method

###### configure_optimizers(self) -> tuple[list[torch.optim.Optimizer], list[(torch.optim.lr_scheduler.LRScheduler|dict[str,
Any])]]: tuple[list[torch.optim.Optimizer], list[(torch.optim.lr_scheduler.LRScheduler|dict[str, Any])]]

Kind: Method

###### load_checkpoint(self, ckpt: PathType | dict [ str , Any ] | None)

Kind: Method

Loads checkpoint weights from provided path.

Loads the checkpoints gracefully, ignoring keys that are not
found in the model state dict or in the checkpoint.

@type ckpt: PathType | dict | None
@param path: Either a path to or a loaded checkpoint. If
C{None}, no checkpoint will be loaded.

###### get_mlflow_logging_keys(self) -> dict[str, list[str]]: dict[str, list[str]]

Kind: Method

Returns a dictionary with two lists of keys:
1) "metrics" -> Keys expected to be logged as standard metrics
2) "artifacts" -> Keys expected to be logged as artifacts (e.g. confusion_matrix.json, visualizations)

##### luxonis_train.lightning.LuxonisOutput

Kind: Class

###### outputs: dict[str, Packet[Tensor]]

Kind: Class Variable

###### losses: dict[str, dict[str, (Tensor|tuple[Tensor, dict[str, Tensor]])]]

Kind: Class Variable

###### visualizations: dict[str, dict[str, Tensor]]

Kind: Class Variable

###### metrics: dict[str, dict[str, Tensor]]

Kind: Class Variable

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

Kind: Method

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

Kind: Method

#### loaders

Kind: Package

##### base_loader

Kind: Module

##### dummy_loader

Kind: Module

##### luxonis_loader_torch

Kind: Module

##### luxonis_perlin_loader_torch

Kind: Module

##### perlin

Kind: Module

###### compute_gradients(res: tuple [ int , int ]) -> Tensor: Tensor

Kind: Function

###### lerp_torch(x: Tensor, y: Tensor, w: Tensor) -> Tensor: Tensor

Kind: Function

###### fade_function(t: Tensor) -> Tensor: Tensor

Kind: Function

###### tile_grads(slice1: tuple [ int , ( int | None ) ], slice2: tuple [ int , ( int | None ) ], gradients: Tensor, d: tuple [
int , int ]) -> Tensor: Tensor

Kind: Function

###### dot(grad: Tensor, shift: tuple [ int , int ], grid: Tensor, shape: tuple [ int , int ]) -> Tensor: Tensor

Kind: Function

###### rand_perlin_2d(shape: tuple [ int , int ], res: tuple [ int , int ], fade: Callable [ [ Tensor ] , Tensor ] =
fade_function) -> Tensor: Tensor

Kind: Function

###### rotate_noise(noise: Tensor) -> Tensor: Tensor

Kind: Function

###### generate_perlin_noise(shape: tuple [ int , int ], min_perlin_scale: int = 0, perlin_scale: int = 6, threshold: float = 0.5)
-> Tensor: Tensor

Kind: Function

###### apply_anomaly_to_img(img: Tensor, anomaly_img: Tensor, beta: float | None = None) -> tuple[Tensor, Tensor]: tuple[Tensor,
Tensor]

Kind: Function

Applies Perlin noise-based anomalies to a single image (C, H, W).

@type img: Tensor
@param img: The input image tensor of shape (C, H, W).
@type anomaly_source_paths: list[str]
@param anomaly_source_paths: List of file paths to the anomaly images.
@type pixel_augs: list[Callable] | None
@param pixel_augs: A list of albumentations augmentations to apply to the anomaly image. Defaults to C{None}.
@type beta: float | None
@param beta: A blending factor for anomaly and noise. If None, a random value in the range [0, 0.8]
is used. Defaults to C{None}.
@rtype: tuple[Tensor, Tensor]
@return: A tuple containing:
- augmented_img (Tensor): The augmented image with applied anomaly and Perlin noise.
- perlin_mask (Tensor): The Perlin noise mask applied to the image.

##### luxonis_train.loaders.BaseLoaderTorch(torch.utils.data.Dataset, abc.ABC)

Kind: Class

###### __init__(self, view: list [ str ], height: int | None = None, width: int | None = None, augmentation_engine: str =
'albumentations', augmentation_config: list [ AugmentationConfig ] | None = None, image_source: str = 'image', keep_aspect_ratio:
bool = True, color_space: Literal [ ' RGB ' , ' BGR ' , ' GRAY ' ] = 'RGB', seed: int | None = None)

Kind: Method

Base abstract loader class that enforces
LuxonisLoaderTorchOutput output label structure.

@type view: list[str]
@param view: List of splits that form the view.
Usually contains only one split, e.g. C{["train"]}
or C{["test"]}. However, more complex datasets
can make use of multi-split views, e.g. C{["train_synthetic",
"train_real"]}.

@type height: int
@param height: Height of the output image.

@type width: int
@param width: Width of the output image.

@type augmentation_engine: str
@param augmentation_engine: Name of the augmentation engine. Can
be used to enable swapping between different augmentation engines or making use of pre-defined engines, e.g.
C{AlbumentationsEngine}.

@type augmentation_config: list[AugmentationConfig] | None
@param augmentation_config: List of augmentation configurations.
Individual configurations are in the form of::

class ConfigItem:
name: str
params: dict[str, JsonValue]

Where C{name} is the name of the augmentation and C{params} is a
dictionary of its parameters.

Example::

ConfigItem(
name="HorizontalFlip",
params={"p": 0.5},
)

@type image_source: str
@param image_source: Name of the image source. Only relevant for
datasets with multiple image sources, e.g. C{"left"} and C{"right"}. This parameter defines which of these sources is used for
visualizations.

@type keep_aspect_ratio: bool
@param keep_aspect_ratio: Whether to keep the aspect ratio of the output image after resizing.

@type color_space: Literal["RGB", "BGR", "GRAY"]
@param color_space: Color space of the output image.

@type seed: Optional[int]
@param seed: The random seed to use for the augmentations.

###### image_source

Kind: Property

Name of the input image group.

###### view

Kind: Property

List of splits forming this dataset's view.

###### augmentation_engine

Kind: Property

Name of the augmentation engine.

###### augmentation_config

Kind: Property

List of augmentation configurations.

###### height

Kind: Property

Height of the output image.

###### width

Kind: Property

Width of the output image.

###### keep_aspect_ratio

Kind: Property

Whether to keep the aspect ratio of the output image after resizing.

###### color_space

Kind: Property

Color space of the output image.

###### seed

Kind: Property

The random seed to use for the augmentations.

###### input_shapes

Kind: Property

Shape (c, h, w) of each loader group (sub-element), WITHOUT batch dimension. Examples:

Single image input:

{
'image': torch.Size([3, 224, 224]),
}

Image and segmentation input:

{
'image': torch.Size([3, 224, 224]),
'segmentation': torch.Size([1, 224, 224]),
}

Left image, right image and disparity input:

{
'left': torch.Size([3, 224, 224]),
'right': torch.Size([3, 224, 224]),
'disparity': torch.Size([1, 224, 224]),
}

Image, keypoints, and point cloud input:

{
'image': torch.Size([3, 224, 224]),
'keypoints': torch.Size([17, 2]),
'point_cloud': torch.Size([20000, 3]),
}

###### input_shape

Kind: Property

Shape (c, h, w) of the input tensor, WITHOUT batch dimension.

###### augment_test_image(self, img: dict [ str , Tensor ]) -> Tensor: Tensor

Kind: Method

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

Kind: Method

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

Kind: Method

Returns length of the dataset.

###### get(self, idx: int) -> tuple[(Tensor|dict[str, Tensor]), Labels]: tuple[(Tensor|dict[str, Tensor]), Labels]

Kind: Method

Loads sample from dataset.

@type idx: int
@param idx: Sample index.
@rtype: L{LuxonisLoaderTorchOutput}
@return: Sample's data in L{LuxonisLoaderTorchOutput} format.

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

Kind: Method

Gets classes according to computer vision task.

@rtype: dict[LabelType, dict[str, int]]
@return: A dictionary mapping tasks to their classes as a
mappings from class name to class IDs.

###### get_n_keypoints(self) -> dict[str, int]|None: dict[str, int]|None

Kind: Method

Returns the dictionary defining the semantic skeleton for
each class using keypoints.

@rtype: dict[str, Dict] | None
@return: A dictionary mapping classes to their skeleton
definitions.

###### get_metadata_types(self) -> dict[str, (type[int]|type[Category]|type[float]|type[str])]: dict[str,
(type[int]|type[Category]|type[float]|type[str])]

Kind: Method

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

Kind: Method

###### dict_numpy_to_torch(self, numpy_dictionary: dict [ str , np.ndarray ]) -> dict[str, Tensor]: dict[str, Tensor]

Kind: Method

Converts a dictionary of numpy arrays to a dictionary of
torch tensors.

@type numpy_dictionary: dict[str, np.ndarray]
@param numpy_dictionary: Dictionary of numpy arrays.
@rtype: dict[str, Tensor]
@return: Dictionary of torch tensors.

###### read_image(self, path: str) -> npt.NDArray[np.uint8]: npt.NDArray[np.uint8]

Kind: Method

Reads an image from a file and returns an unnormalized image
as a numpy array.

@type path: str
@param path: Path to the image file.
@rtype: np.ndarray[np.uint8]
@return: Image as a numpy array.

###### img_numpy_to_torch(img: np.ndarray) -> Tensor: Tensor

Kind: Static Method

###### collate_fn(self, batch: list [ LuxonisLoaderTorchOutput ]) -> tuple[dict[str, Tensor], Labels]: tuple[dict[str, Tensor],
Labels]

Kind: Method

Default collate function used for training.

@type batch: list[LuxonisLoaderTorchOutput]
@param batch: List of loader outputs (dict of Tensors) and
labels (dict of Tensors) in the LuxonisLoaderTorchOutput
format.
@rtype: tuple[dict[str, Tensor], dict[str, Tensor]]
@return: Tuple of inputs and annotations in the format expected
by the model.

##### LuxonisLoaderTorchOutput

Kind: Type Alias

##### luxonis_train.loaders.DummyLoader(luxonis_train.loaders.BaseLoaderTorch)

Kind: Class

A dummy data loader for testing purposes.

It serves as a placeholder in place of LuxonisLoaderTorch when no real data is available.

It can be extended to be used instead of custom loaders as well by overriding the get_label_shapes method.

###### __init__(self, cfg: Config, view: list [ str ], height: int | None = None, width: int | None = None, image_source: str =
'image', color_space: Literal [ ' RGB ' , ' BGR ' , ' GRAY ' ] = 'RGB', n_keypoints: int = 3, n_classes: int = 1, class_names:
list [ str ] | dict [ str , int ] | dict [ str , dict [ str , int ] ] | None = None, kwargs)

Kind: Method

###### n_keypoints

Kind: Instance Variable

###### n_classes

Kind: Instance Variable

###### batch_size

Kind: Instance Variable

###### labels

Kind: Instance Variable

###### n_channels

Kind: Instance Variable

###### class_names

Kind: Instance Variable

###### input_shapes

Kind: Property

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

Kind: Method

###### get(self, idx: int) -> tuple[(Tensor|dict[str, Tensor]), Labels]: tuple[(Tensor|dict[str, Tensor]), Labels]

Kind: Method

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

Kind: Method

###### get_n_keypoints(self) -> dict[str, int]|None: dict[str, int]|None

Kind: Method

###### get_label_shapes(self, labels: dict [ str , set [ ( str | Metadata ) ] ]) -> dict[str, tuple[int, ...]]: dict[str,
tuple[int, ...]]

Kind: Method

Creates a dictionary with shape information for each label
based on the task type.

Handles all LDF-native labels by default, but needs to be
extended for custom loaders.

##### luxonis_train.loaders.LuxonisLoaderTorch(luxonis_train.loaders.BaseLoaderTorch)

Kind: Class

###### __init__(self, dataset_name: str | None = None, dataset_dir: str | None = None, dataset_type: DatasetType | None = None,
team_id: str | None = None, bucket_type: Literal [ ' internal ' , ' external ' ] = 'internal', bucket_storage: Literal [ ' local '
, ' s3 ' , ' gcs ' , ' azure ' ] = 'local', update_mode: Literal [ ' all ' , ' missing ' ] = 'all', delete_existing: bool = True,
filter_task_names: list [ str ] | None = None, min_bbox_visibility: float = 0.0, bbox_area_threshold: float = 0.0004,
class_order_per_task: dict [ str , list [ str ] ] | None = None, kpts_mapping_per_task: dict [ str , list [ int ] ] | None = None,
kwargs)

Kind: Method

Torch-compatible loader for Luxonis datasets.

Can either use an already existing dataset or parse a new one
from a directory.

@type dataset_name: str | None
@param dataset_name: Name of the dataset to load. If not
provided, the C{dataset_dir} argument must be provided
instead. If both C{dataset_dir} and C{dataset_name} are
provided, the dataset will be parsed from the directory and
saved with the provided name.
@type dataset_dir: str | None
@param dataset_dir: Path to the dataset directory. It can be
either a local path or a URL. The data can be in a zip file.
If not provided, C{dataset_name} of an existing dataset must
be provided.
@type dataset_type: str | None
@param dataset_type: Type of the dataset. Only relevant when
C{dataset_dir} is provided. If not provided, the type will
be inferred from the directory structure.
@type team_id: str | None
@param team_id: Optional unique team identifier for the cloud.
@type bucket_type: Literal["internal", "external"]
@param bucket_type: Type of the bucket. Only relevant for remote
datasets. Defaults to 'internal'.
@type bucket_storage: Literal["local", "s3", "gcs", "azure"]
@param bucket_storage: Type of the bucket storage. Defaults to
'local'.
@type update_mode: Literal["all", "missing"]
@param update_mode: Enum that determines the sync mode for media files of the remote dataset (annotations and metadata are always
overwritten):
- UpdateMode.MISSING: Downloads only the missing media files for the dataset.
- UpdateMode.ALL: Always downloads and overwrites all media files in the local dataset.
@type delete_existing: bool
@param delete_existing: Only relevant when C{dataset_dir} is
provided. By default, the dataset is parsed again every time
the loader is created because the underlying data might have
changed. If C{delete_existing} is set to C{False} and a
dataset of the same name already exists, the existing
dataset will be used instead of re-parsing the data.
@type filter_task_names: list[str] | None
@param filter_task_names: List of task names to filter the
dataset by. If provided, only the tasks with the specified
names will be loaded. If not provided, all tasks will be
loaded.
@type min_bbox_visibility: float
@param min_bbox_visibility: Minimum fraction of the original bounding box that must remain visible after augmentation.
@type bbox_area_threshold: float
@param bbox_area_threshold: Minimum area threshold for bounding boxes to be considered valid. In the range [0, 1].
Default is 0.0004, which corresponds to a small area threshold to remove invalid bboxes and respective keypoints.
@type class_order_per_task: dict[str, list[str]] | None
@param class_order_per_task: Dictionary mapping task names to a list of class names.
If provided, the classes for the specified tasks will be reordered.
@type kpts_mapping_per_task: dict[str, list[int]] | None
@param kpts_mapping_per_task: Dictionary mapping task names to custom keypoint mappings. If provided, the keypoints for the
specified tasks will be reordered.

###### dataset

Kind: Instance Variable

###### kpts_mapping_per_task

Kind: Instance Variable

###### loader

Kind: Instance Variable

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

Kind: Method

###### input_shapes

Kind: Property

###### get(self, idx: int) -> tuple[dict[str, Tensor], Labels]: tuple[dict[str, Tensor], Labels]

Kind: Method

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

Kind: Method

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

Kind: Method

###### get_metadata_types(self) -> dict[str, (type[int]|type[Category]|type[float]|type[str])]: dict[str,
(type[int]|type[Category]|type[float]|type[str])]

Kind: Method

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

Kind: Method

###### augment_test_image(self, img: dict [ str , Tensor ]) -> Tensor: Tensor

Kind: Method

##### luxonis_train.loaders.LuxonisLoaderPerlinNoise(luxonis_train.loaders.LuxonisLoaderTorch)

Kind: Class

###### __init__(self, args, anomaly_source_path: PathType, noise_prob: float = 0.5, beta: float | None = None, kwargs)

Kind: Method

Custom loader for LDF that adds Perlin noise during training
with a given probability.

@type anomaly_source_path: str
@param anomaly_source_path: Path to the anomaly dataset from
where random samples are drawn for noise.
@type noise_prob: float
@param noise_prob: The probability with which to apply Perlin
noise.
@type beta: float
@param beta: The opacity of the anomaly mask. If None, a random
value is chosen. It's advisable to set it to None.

###### anomaly_source_path

Kind: Instance Variable

###### anomaly_files

Kind: Instance Variable

###### noise_prob

Kind: Instance Variable

###### beta

Kind: Instance Variable

###### task_name

Kind: Instance Variable

###### augmentations

Kind: Instance Variable

###### get(self, idx: int) -> tuple[Tensor, Labels]: tuple[Tensor, Labels]

Kind: Method

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

Kind: Method

#### nodes

Kind: Package

##### backbones

Kind: Package

###### contextspatial

Kind: Module

###### luxonis_train.nodes.backbones.contextspatial.SpatialPath(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, out_channels: int)

Kind: Method

###### conv_7x7

Kind: Instance Variable

###### conv_3x3_1

Kind: Instance Variable

###### conv_3x3_2

Kind: Instance Variable

###### conv_1x1

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.backbones.contextspatial.ContextPath(torch.nn.Module)

Kind: Class

###### __init__(self, backbone: nn.Module)

Kind: Method

###### backbone

Kind: Instance Variable

###### up16

Kind: Instance Variable

###### up32

Kind: Instance Variable

###### refine16

Kind: Instance Variable

###### refine32

Kind: Instance Variable

###### forward(self, x: Tensor) -> tuple[Tensor, Tensor]: tuple[Tensor, Tensor]

Kind: Method

###### arm16

Kind: Instance Variable

###### arm32

Kind: Instance Variable

###### global_context

Kind: Instance Variable

###### ddrnet

Kind: Package

###### blocks

Kind: Module

DDRNet blocks.

Adapted from:
https://github.com/Deci-AI/super-gradients/blob/master/src/super_gradients/training/models/segmentation_models/ddrnet.py Original
source: https://github.com/ydhongHIT/DDRNet Paper: https://arxiv.org/pdf/2101.06085.pdf

###### luxonis_train.nodes.backbones.ddrnet.blocks.DAPPMBranch(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, kernel_size: int, stride: int, branch_channels: int, interpolation_mode: str = 'bilinear')

Kind: Method

A DAPPM branch.

@type in_channels: int
@param in_channels: Number of input channels.
@type kernel_size: int
@param kernel_size: The kernel size. When stride=0, this
parameter is omitted, and AdaptiveAvgPool2d over all the
input is performed.
@type stride: int
@param stride: Stride for the first convolution. When stride is
set to 0, C{AdaptiveAvgPool2d} over all the input is
performed (output is 1x1). When set to 1, no operation is
performed. When stride>1, a convolution with
C{stride=stride} is performed.
@type branch_channels: int
@param branch_channels: Width after the first convolution.
@type interpolation_mode: str
@param interpolation_mode: Interpolation mode for upscaling.
Defaults to "bilinear".

###### down_scale

Kind: Instance Variable

###### up_scale

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.backbones.ddrnet.blocks.MergeDAPPMBranch(luxonis_train.nodes.backbones.ddrnet.blocks.DAPPMBranch)

Kind: Class

###### __init__(self, in_channels: int, kernel_size: int, stride: int, branch_channels: int, interpolation_mode: str = 'bilinear')

Kind: Method

A DAPPM branch working with an input from the previous
branch.

@type kernel_size: int
@param kernel_size: The kernel size. When stride=0, this
parameter is omitted, and AdaptiveAvgPool2d over all the
input is performed.
@type stride: int
@param stride: Stride for the first convolution. When stride is
set to 0, C{AdaptiveAvgPool2d} over all the input is
performed (output is 1x1). When set to 1, no operation is
performed. When stride>1, a convolution with
C{stride=stride} is performed.
@type in_channels: int
@param in_channels: Number of input channels.
@type branch_channels: int
@param branch_channels: Width after the first convolution.
@type interpolation_mode: str
@param interpolation_mode: Interpolation mode for upscaling.
Defaults to "bilinear".

###### process

Kind: Instance Variable

###### forward(self, x: Tensor, skip_x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.backbones.ddrnet.blocks.DAPPM(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, branch_channels: int, out_channels: int, kernel_sizes: list [ int ], strides: list [ int
], interpolation_mode: str = 'bilinear')

Kind: Method

DAPPM (Dynamic Attention Pyramid Pooling Module).

@type in_channels: int
@param in_channels: Number of input channels.
@type branch_channels: int
@param branch_channels: Width after the first convolution in
each branch.
@type out_channels: int
@param out_channels: Number of output channels.
@type kernel_sizes: list[int]
@param kernel_sizes: List of kernel sizes for each branch.
@type strides: list[int]
@param strides: List of strides for each branch.
@type interpolation_mode: str
@param interpolation_mode: Interpolation mode for upscaling.
Defaults to "bilinear".
@raises ValueError: If the lengths of C{kernel_sizes} and
C{strides} are not the same.

###### start_branch

Kind: Instance Variable

###### branches

Kind: Instance Variable

###### compression

Kind: Instance Variable

###### shortcut

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

Forward pass through the DAPPM module.

@type x: Tensor
@param x: Input tensor.
@return: Output tensor after processing through all branches and
compression.

###### luxonis_train.nodes.backbones.ddrnet.blocks.BasicDDRBackbone(torch.nn.Module)

Kind: Class

###### __init__(self, block: type [ nn.Module ], stem_channels: int, layers: list [ int ], in_channels: int, layer3_repeats: int =
1)

Kind: Method

Initialize the BasicDDRBackBone with specified parameters.

@type block: Type[nn.Module]
@param block: The block class to use for layers.
@type stem_channels: int
@param stem_channels: Number of output channels in the stem layer.
@type layers: list[int]
@param layers: Number of blocks in each layer.
@type in_channels: int
@param in_channels: Number of input channels.
@type layer3_repeats: int
@param layer3_repeats: Number of repeats for layer3. Defaults to
1.

###### input_channels

Kind: Instance Variable

###### stem

Kind: Instance Variable

###### layer1

Kind: Instance Variable

###### layer2

Kind: Instance Variable

###### layer3

Kind: Instance Variable

###### layer4

Kind: Instance Variable

###### get_backbone_output_number_of_channels(self) -> dict[str, int]: dict[str, int]

Kind: Method

Determine the number of output channels for each layer of the
backbone.

Returns a dictionary with keys "layer2", "layer3", "layer4" and
their respective number of output channels.

@return: Dictionary of output channel counts for each layer.

###### make_layer(block: type [ nn.Module ], in_channels: int, channels: int, n_blocks: int, stride: int = 1, expansion: int = 1)
-> nn.Sequential: nn.Sequential

Kind: Function

Creates a sequential layer consisting of a series of blocks.

@type block: Type[nn.Module]
@param block: The block class to be used.
@type in_channels: int
@param in_channels: Number of input channels.
@type channels: int
@param channels: Number of output channels.
@type n_blocks: int
@param n_blocks: Number of blocks in the layer.
@type stride: int
@param stride: Stride for the first block. Defaults to 1.
@type expansion: int
@param expansion: Expansion factor for the block. Defaults to 1.
@return: A sequential container of the blocks.

###### ddrnet

Kind: Module

###### luxonis_train.nodes.backbones.ddrnet.DDRNet(luxonis_train.nodes.base_node.BaseNode)

Kind: Class

DDRNet backbone for semantic segmentation.

Variants

The variant determines the number of channels and high resolution channels. The following variants are available:

"23-slim" (default): channels=32, high_resolution_channels=64

"23": channels=64, high_resolution_channels=128

###### in_channels: int

Kind: Class Variable

###### __init__(self, channels: int = 32, high_resolution_channels: int = 64, use_aux_heads: bool = True, upscale_module:
nn.Module | None = None, spp_width: int = 128, ssp_interpolation_mode: str = 'bilinear', segmentation_interpolation_mode: str =
'bilinear', block: type [ nn.Module ] = ResNetBlock, skip_block: type [ nn.Module ] = ResNetBlock, layer5_block: type [ nn.Module
] = ResNetBottleneck, layer5_bottleneck_expansion: int = 2, spp_kernel_sizes: list [ int ] | None = None, spp_strides: list [ int
] | None = None, layer3_repeats: int = 1, layers: list [ int ] | None = None, kwargs)

Kind: Method

DDRNet backbone.

@see: U{Adapted from <https://github.com/Deci-AI/super-gradients/blob/master/src
/super_gradients/training/models/segmentation_models/ddrnet.py>}
@see: U{Original code <https://github.com/ydhongHIT/DDRNet>}
@see: U{Paper <https://arxiv.org/pdf/2101.06085.pdf>}
@license: U{Apache License, Version 2.0 <https://github.com/Deci-AI/super-
gradients/blob/master/LICENSE.md>}
@type channels: int | None
@param channels: Base number of channels. If provided, overrides the variant values.
@type high_resolution_channels: int | None
@param high_resolution_channels: Number of channels in the high resolution net.
If provided, overrides the variant values.
@type use_aux_heads: bool
@param use_aux_heads: Whether to use auxiliary heads. Defaults to True.
@type upscale_module: nn.Module
@param upscale_module: Module for upscaling (e.g., bilinear interpolation).
Defaults to UpscaleOnline().
@type spp_width: int
@param spp_width: Width of the branches in the SPP block. Defaults to 128.
@type ssp_interpolation_mode: str
@param ssp_interpolation_mode: Interpolation mode for the SPP block. Defaults to
"bilinear".
@type segmentation_interpolation_mode: str
@param segmentation_interpolation_mode: Interpolation mode for the segmentation head.
Defaults to "bilinear".
@type block: type[nn.Module]
@param block: type of block to use in the backbone. Defaults to
ResNetBlock.
@type skip_block: type[nn.Module]
@param skip_block: type of block for skip connections. Defaults to
ResNetBlock.
@type layer5_block: type[nn.Module]
@param layer5_block: type of block for layer5 and layer5_skip. Defaults to
Bottleneck.
@type layer5_bottleneck_expansion: int
@param layer5_bottleneck_expansion: Expansion factor for Bottleneck block in
layer5. Defaults to 2.
@type spp_kernel_sizes: list[int]
@param spp_kernel_sizes: Kernel sizes for the SPP module pooling. Defaults to
[1, 5, 9, 17, 0].
@type spp_strides: list[int]
@param spp_strides: Strides for the SPP module pooling. Defaults to [1, 2, 4, 8,
0].
@type layer3_repeats: int
@param layer3_repeats: Number of times to repeat the 3rd stage. Defaults to 1.
@type layers: list[int]
@param layers: Number of blocks in each layer of the backbone. Defaults to [2,
2, 2, 2, 1, 2, 2, 1].

###### upscale

Kind: Instance Variable

###### ssp_interpolation_mode

Kind: Instance Variable

###### segmentation_interpolation_mode

Kind: Instance Variable

###### relu

Kind: Instance Variable

###### layer3_repeats

Kind: Instance Variable

###### channels

Kind: Instance Variable

###### layers

Kind: Instance Variable

###### backbone_layers

Kind: Instance Variable

###### additional_layers

Kind: Instance Variable

###### backbone

Kind: Instance Variable

###### compression3

Kind: Instance Variable

###### down3

Kind: Instance Variable

###### layer3_skip

Kind: Instance Variable

###### compression4

Kind: Instance Variable

###### down4

Kind: Instance Variable

###### layer4_skip

Kind: Instance Variable

###### layer5_skip

Kind: Instance Variable

###### layer5

Kind: Instance Variable

###### spp

Kind: Instance Variable

###### forward(self, inputs: Tensor) -> list[Tensor]: list[Tensor]

Kind: Method

###### initialize_weights(self, method: str | None = None)

Kind: Method

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

Kind: Method

###### get_variants() -> tuple[str, dict[str, Kwargs]]: tuple[str, dict[str, Kwargs]]

Kind: Static Method

###### dinov3

Kind: Package

###### dinov3

Kind: Module

###### luxonis_train.nodes.backbones.dinov3.dinov3.TransformerBackboneReturnsIntermediateLayers(torch.nn.Module)

Kind: Class

Minimal interface for DINOv3 models.

To properly declare the dinov3.models.vision_transformer.DinoVisionTransformer type, the DINOv3 repository needs to be cloned
locally.

###### embed_dim: int

Kind: Class Variable

###### num_heads: int

Kind: Class Variable

###### rope_embed: nn.Module

Kind: Class Variable

###### get_intermediate_layers(self, x: Tensor, n: int, norm: bool, return_class_token: bool) -> list[Tensor]|list[tuple[Tensor,
Tensor]]: list[Tensor]|list[tuple[Tensor, Tensor]]

Kind: Method

###### DINOv3Variant: TypeAlias

Kind: Type Alias

###### rope_position_encoding

Kind: Module

###### luxonis_train.nodes.backbones.dinov3.rope_position_encoding.RopePositionEmbedding(torch.nn.Module)

Kind: Class

###### periods: Tensor

Kind: Class Variable

###### __init__(self, embed_dim: int, num_heads: int, base: float | None = 100.0, min_period: float | None = None, max_period:
float | None = None, normalize_coords: Literal [ ' min ' , ' max ' , ' separate ' ] = 'separate', shift_coords: float | None =
None, jitter_coords: float | None = None, rescale_coords: float | None = None, dtype: torch.dtype | None = None, device:
torch.device | None = None)

Kind: Method

###### base

Kind: Instance Variable

###### min_period

Kind: Instance Variable

###### max_period

Kind: Instance Variable

###### D_head

Kind: Instance Variable

###### normalize_coords

Kind: Instance Variable

###### shift_coords

Kind: Instance Variable

###### jitter_coords

Kind: Instance Variable

###### rescale_coords

Kind: Instance Variable

###### dtype

Kind: Instance Variable

###### forward(self, H: int, W: int) -> tuple[Tensor, Tensor]: tuple[Tensor, Tensor]

Kind: Method

###### luxonis_train.nodes.backbones.dinov3.DinoV3(luxonis_train.nodes.base_node.BaseNode)

Kind: Class

DINOv3 backbone: a self-supervised vision transformer encoder that learns strong, dense feature representations useful for various
downstream tasks.

Source: https://github.com/facebookresearch/dinov3

###### in_height: int

Kind: Class Variable

###### in_width: int

Kind: Class Variable

###### __init__(self, weights_link: str, return_sequence: bool = False, variant: DINOv3Variant = 'vits16', repo_or_dir: str =
'facebookresearch/dinov3', freeze_backbone: bool = False, depth: int = 4, kwargs)

Kind: Method

@param weights:link: a weights link for the specific model,
which needs to be requested here U{https://pytorch.org/get-
started/locally/}
@type weights_link: string

@param return_sequence: If True, return the CLS embedding
[B, C] for downstream classification heads. Otherwise, turn
patch embeddings into [B, C, H, W] feature maps to be passed
to dense prediction heads
@type return_sequence: bool

@param variant: Architecture variant of the DINOv3 backbone.
@type variant: Literal DINOv3Variant.

@param repo_dir: "facebookresearch/dinov3" if the repository
is not locally downloaded or cached, "local" otherwise
@type repo_dir: str

@param freeze_backbone: if True, freeze the backbone;
this will lead to a transfer learning scenario where
only the head contains trainable parameters
@type freeze_backbone: bool

@param depth: number of last layers that are taken
from the transformer output and converted to feature maps
@type depth: int

###### return_sequence

Kind: Instance Variable

###### depth

Kind: Instance Variable

###### backbone

Kind: Instance Variable

###### patch_size

Kind: Instance Variable

###### forward(self, inputs: Tensor) -> list[Tensor]: list[Tensor]

Kind: Method

If self.return_sequence is True, a list containing the CLS
token embedding [B, C] is returned and this can be used for
downstream classification tasks.

Otherwise, the last `self.depth` layers of the network are
returned as [B, C, H, W] feature maps, which can be used for
downstream segmentation and other dense feature tasks

###### get_variants() -> tuple[str, dict[str, Kwargs]]: tuple[str, dict[str, Kwargs]]

Kind: Static Method

###### efficientnet

Kind: Module

###### efficientrep

Kind: Package

###### efficientrep

Kind: Module

###### luxonis_train.nodes.backbones.efficientrep.EfficientRep(luxonis_train.nodes.base_node.BaseNode)

Kind: Class

EfficientRep backbone for object detection.

Variants

The variant determines the depth and width multipliers, block used and intermediate channel scaling factor.

The depth multiplier determines the number of blocks in each stage and the width multiplier determines the number of channels.

The following variants are available:

"n" or "nano" (default): depth_multiplier=0.33, width_multiplier=0.25, block=RepBlock, e=None

"s" or "small": depth_multiplier=0.33, width_multiplier=0.50, block=RepBlock, e=None

"m" or "medium": depth_multiplier=0.60, width_multiplier=0.75, block=CSPStackRepBlock, e=2/3

"l" or "large": depth_multiplier=1.0, width_multiplier=1.0, block=CSPStackRepBlock, e=1/2

###### in_channels: int

Kind: Class Variable

###### __init__(self, channels_list: list [ int ] | None = None, n_repeats: list [ int ] | None = None, depth_multiplier: float =
0.33, width_multiplier: float = 0.25, block: Literal [ ' RepBlock ' , ' CSPStackRepBlock ' ] = 'RepBlock', csp_e: float = 0.5,
weights: str = 'yolo', kwargs)

Kind: Method

Implementation of the EfficientRep backbone. Supports the
version with RepBlock and CSPStackRepBlock (for larger networks)

Adapted from U{YOLOv6: A Single-Stage Object Detection Framework
for Industrial Applications
<https://arxiv.org/pdf/2209.02976.pdf>}.

@type channels_list: list[int] | None
@param channels_list: List of number of channels for each block.
If unspecified, defaults to [64, 128, 256, 512, 1024].
@type n_repeats: list[int] | None
@param n_repeats: List of number of repeats of RepVGGBlock. If
unspecified, defaults to [1, 6, 12, 18, 6].
@type depth_mul: float
@param depth_mul: Depth multiplier. If provided, overrides the
variant value.
@type width_mul: float
@param width_mul: Width multiplier. If provided, overrides the
variant value.
@type block: Literal["RepBlock", "CSPStackRepBlock"] | None
@param block: Base block used when building the backbone. If
provided, overrides the variant value.
@type csp_e: float | None
@param csp_e: Factor that controls number of intermediate
channels if block="CSPStackRepBlock". If provided, overrides
the variant value.

###### repvgg_encoder

Kind: Instance Variable

###### blocks

Kind: Instance Variable

###### forward(self, inputs: Tensor) -> list[Tensor]: list[Tensor]

Kind: Method

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

Kind: Method

###### get_variants() -> tuple[str, dict[str, Kwargs]]: tuple[str, dict[str, Kwargs]]

Kind: Static Method

###### efficientvit

Kind: Package

###### blocks

Kind: Module

###### luxonis_train.nodes.backbones.efficientvit.blocks.DepthWiseSeparableConv(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, out_channels: int, kernel_size: int = 3, stride: int = 1, depthwise_bias: bool = False,
pointwise_bias: bool = False, depthwise_activation: nn.Module | None = None, pointwise_activation: nn.Module | None = None,
padding: int | str | None = None, dilation: int | tuple [ int , int ] = 1, use_residual: bool = False)

Kind: Method

Depthwise separable convolution.

@type in_channels: int
@param in_channels: Number of input channels.
@type out_channels: int
@param out_channels: Number of output channels.
@type kernel_size: int
@param kernel_size: Kernel size. Defaults to 3.
@type stride: int
@param stride: Stride. Defaults to 1.
@type depthwise_bias: bool
@param depthwise_bias: Whether to use bias for the depthwise
convolution.
@type pointwise_bias: bool
@param pointwise_bias: Whether to use bias for the pointwise
convolution.
@type depthwise_activation: nn.Module
@param depthwise_activation: Activation function for the
depthwise convolution. Defaults to nn.ReLU6().
@type pointwise_activation: nn.Module
@param pointwise_activation: Activation function for the
pointwise convolution.
@type padding: int | str | None
@param padding: Padding. Defaults to None.
@type dilation: int | tuple[int, int]
@param dilation: Dilation. Defaults to 1.

###### use_residual

Kind: Instance Variable

###### depthwise_conv

Kind: Instance Variable

###### pointwise_conv

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.backbones.efficientvit.blocks.MobileBottleneckBlock(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, out_channels: int, kernel_size: int = 3, stride: int = 1, expand_ratio: float = 6,
use_bias: list [ bool ] | None = None, use_norm: list [ bool ] | None = None, activation: list [ nn.Module ] | None = None,
use_residual: bool = False)

Kind: Method

MobileBottleneckBlock is a block used in the EfficientViT
model.

@type in_channels: int
@param in_channels: Number of input channels.
@type out_channels: int
@param out_channels: Number of output channels.
@type kernel_size: int
@param kernel_size: Kernel size. Defaults to 3.
@type stride: int
@param stride: Stride. Defaults to 1.
@type expand_ratio: float
@param expand_ratio: Expansion ratio. Defaults to 6.
@type use_bias: list[bool, bool, bool]
@param use_bias: Whether to use bias for the depthwise and
pointwise convolutions.
@type use_norm: list[bool, bool, bool]
@param use_norm: Whether to use normalization for the depthwise
and pointwise convolutions.
@type activation: list[nn.Module, nn.Module, nn.Module]
@param activation: Activation functions for the depthwise and
pointwise convolutions.
@type use_residual: bool
@param use_residual: Whether to use residual connection.
Defaults to False.

###### use_residual

Kind: Instance Variable

###### expand_conv

Kind: Instance Variable

###### depthwise_conv

Kind: Instance Variable

###### project_conv

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.backbones.efficientvit.blocks.EfficientViTBlock(torch.nn.Module)

Kind: Class

###### __init__(self, n_channels: int, attention_ratio: float = 1.0, head_dim: int = 32, expansion_factor: float = 4.0,
aggregation_scales: tuple [ int , ... ] = (5))

Kind: Method

EfficientVisionTransformerBlock is a modular component
designed for multi-scale linear attention and local feature
processing.

@type n_channels: int
@param n_channels: The number of input and output channels.
@type attention_ratio: float
@param attention_ratio: Ratio for determining the number of attention heads. Default is 1.0.
@type head_dim: int
@param head_dim: Dimension size for each attention head. Default is 32.
@type expansion_factor: float
@param expansion_factor: Factor by which channels expand in the local module. Default is 4.0.
@type aggregation_scales: tuple[int, ...]
@param aggregation_scales: Tuple defining the scales for aggregation in the attention module. Default is (5,).

###### attention_module

Kind: Instance Variable

###### feature_module

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

Forward pass of the block.

@param x: Input tensor with shape [batch, channels, height,
width].
@return: Output tensor after attention and local feature
processing.

###### luxonis_train.nodes.backbones.efficientvit.blocks.LightweightMLABlock(torch.nn.Module)

Kind: Class

###### __init__(self, input_channels: int, output_channels: int, n_heads: int | None = None, head_ratio: float = 1.0, dimension:
int = 8, use_bias: list [ bool ] | None = None, use_norm: list [ bool ] | None = None, activations: list [ nn.Module ] | None =
None, scale_factors: tuple [ int , ... ] = (5), epsilon: float = 1e-15, use_residual: bool = True, kernel_activation: nn.Module |
None = None)

Kind: Method

LightweightMLABlock is a modular component used in the
EfficientViT framework. It facilitates efficient multi-scale
linear attention.

@type input_channels: int
@param input_channels: Number of input channels.
@type output_channels: int
@param output_channels: Number of output channels.
@type n_heads: int
@param n_heads: Number of attention heads. Default is None.
@type head_ratio: float
@param head_ratio: Ratio to determine the number of heads.
Default is 1.0.
@type dimension: int
@param dimension: Size of each head. Default is 8.
@type use_bias: list[bool, bool]
@param biases: List specifying if bias is used in qkv and
projection layers.
@type use_norm: list[bool, bool]
@param norms: List specifying if normalization is applied in qkv
and projection layers.
@type activations: list[nn.Module, nn.Module]
@param activations: List of activation functions for qkv and
projection layers.
@type scale_factors: tuple[int, ...]
@param scale_factors: Tuple defining scales for aggregation.
Default is (5,).
@type epsilon: float
@param epsilon: Epsilon value for numerical stability. Default
is 1e-15.

###### epsilon

Kind: Instance Variable

###### use_residual

Kind: Instance Variable

###### dimension

Kind: Instance Variable

###### qkv_layer

Kind: Instance Variable

###### multi_scale_aggregators

Kind: Instance Variable

###### kernel_activation

Kind: Instance Variable

###### projection_layer

Kind: Instance Variable

###### linear_attention(self, qkv_tensor: Tensor) -> Tensor: Tensor

Kind: Method

Implements ReLU-based linear attention.

###### quadratic_attention(self, qkv_tensor: Tensor) -> Tensor: Tensor

Kind: Method

Implements ReLU-based quadratic attention.

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### efficientvit

Kind: Module

###### luxonis_train.nodes.backbones.efficientvit.EfficientViT(luxonis_train.nodes.base_node.BaseNode)

Kind: Class

EfficientViT backbone implementation based on a lightweight transformer architecture.

This implementation is inspired by the architecture described in the paper: "EfficientViT: Multi-Scale Linear Attention for
High-Resolution Dense Prediction" (https://arxiv.org/abs/2205.14756).

The EfficientViT model is designed to provide a balance between computational efficiency and performance, making it suitable for
deployment on edge devices with limited resources.

Variants

The variant determines the width, depth, and dimension of the network. Available variants are:

"n" or "nano" (default): width_list=[8, 16, 32, 64, 128], depth_list=[1, 2, 2, 2, 2], dim=16

"s" or "small": width_list=[16, 32, 64, 128, 256], depth_list=[1, 2, 3, 3, 4], dim=16

"m" or "medium": width_list=[24, 48, 96, 192, 384], depth_list=[1, 3, 4, 4, 6], dim=32

"l" or "large": width_list=[32, 64, 128, 256, 512], depth_list=[1, 4, 6, 6, 9], dim=32

###### in_channels: int

Kind: Class Variable

###### __init__(self, width_list: list [ int ] | None = None, depth_list: list [ int ] | None = None, dim: int = 16, expand_ratio:
int = 4, kwargs)

Kind: Method

@type width_list: list[int]
@param width_list: List of number of channels for each block.
@type depth_list: list[int]
@param depth_list: List of number of layers in each block.
@type dim: int | None
@param dim: Dimension of the transformer.
@type expand_ratio: int
@param expand_ratio: Expansion ratio for the L{MobileBottleneckBlock}. Defaults to C{4}.

###### feature_extractor

Kind: Instance Variable

###### encoder_blocks

Kind: Instance Variable

###### forward(self, x: Tensor) -> list[Tensor]: list[Tensor]

Kind: Method

###### get_variants() -> tuple[str, dict[str, Kwargs]]: tuple[str, dict[str, Kwargs]]

Kind: Static Method

###### ghostfacenet

Kind: Package

###### blocks

Kind: Module

###### luxonis_train.nodes.backbones.ghostfacenet.blocks.OriginalGhostModuleV2(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, out_channels: int, kernel_size: int = 1, ratio: int = 2, dw_size: int = 3, stride: int =
1, use_prelu: bool = True)

Kind: Method

###### out_channels

Kind: Instance Variable

###### primary_conv

Kind: Instance Variable

###### cheap_operation

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

######
luxonis_train.nodes.backbones.ghostfacenet.blocks.AttentionGhostModuleV2(luxonis_train.nodes.backbones.ghostfacenet.blocks.OriginalGhostModuleV2)

Kind: Class

###### __init__(self, in_channels: int, out_channels: int, kernel_size: int = 1, ratio: int = 2, dw_size: int = 3, stride: int =
1, use_prelu: bool = True)

Kind: Method

###### short_conv

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.backbones.ghostfacenet.blocks.GhostBottleneckV2(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, hidden_channels: int, out_channels: int, kernel_size: int = 3, stride: int = 1, se_ratio:
float = 0.0, mode: Literal [ ' original ' , ' attention ' ])

Kind: Method

###### stride

Kind: Instance Variable

###### ghost1

Kind: Instance Variable

###### conv_dw

Kind: Instance Variable

###### bn_dw

Kind: Instance Variable

###### se

Kind: Instance Variable

###### ghost2

Kind: Instance Variable

###### shortcut

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.backbones.ghostfacenet.blocks.GhostBottleneckLayer(torch.nn.Sequential)

Kind: Class

###### __init__(self, width_multiplier: int, input_channel: int, kernel_sizes: list [ int ], expand_sizes: list [ int ],
output_channels: list [ int ], se_ratios: list [ float ], strides: list [ int ], mode: Literal [ ' original ' , ' attention ' ])

Kind: Method

###### output_channel

Kind: Instance Variable

###### ghostfacenet

Kind: Module

###### luxonis_train.nodes.backbones.ghostfacenet.ghostfacenet.LayerParamsDict(typing.TypedDict)

Kind: Class

###### mode: Literal['original', 'attention']

Kind: Class Variable

###### kernel_sizes: list[int]

Kind: Class Variable

###### expand_sizes: list[int]

Kind: Class Variable

###### output_channels: list[int]

Kind: Class Variable

###### se_ratios: list[float]

Kind: Class Variable

###### strides: list[int]

Kind: Class Variable

###### luxonis_train.nodes.backbones.ghostfacenet.ghostfacenet.VariantParamsDict(typing.TypedDict)

Kind: Class

###### width_multiplier: int

Kind: Class Variable

###### layer_params: list[LayerParamsDict]

Kind: Class Variable

###### luxonis_train.nodes.backbones.ghostfacenet.GhostFaceNet(luxonis_train.nodes.base_node.BaseNode)

Kind: Class

GhostFaceNetsV2 backbone.

GhostFaceNetsV2 is a convolutional neural network architecture focused on face recognition, but it is adaptable to generic
embedding tasks. It is based on the GhostNet architecture and uses Ghost BottleneckV2 blocks.

Source: https://github.com/Hazqeel09/ellzaf_ml/blob/main/ellzaf_ml/models/ghostfacenetsv2.py

Variants

This backbone offers a single variant, V2, which is the default variant.

###### in_channels: int

Kind: Class Variable

###### in_width: int

Kind: Class Variable

###### __init__(self, width_multiplier: int, layer_params: list [ LayerParamsDict ], kwargs)

Kind: Method

@type width_multiplier: int
@param width_multiplier: Width multiplier for the blocks.
@type kernel_sizes: list[list[int]]
@param kernel_sizes: List of kernel sizes for block in each stage.
@type expand_sizes: list[list[int]]
@param expand_sizes: List of expansion sizes for block in each stage.
@type output_channels: list[list[int]]
@param output_channels: List of output channels for block in each stage.
@type se_ratios: list[list[float]]
@param se_ratios: List of Squeeze-and-Excitation ratios for block in each stage.
@type strides: list[list[int]]
@param strides: List of strides for block in each stage.

###### layers

Kind: Instance Variable

###### initialize_weights(self, method: str | None = None)

Kind: Method

###### forward(self, x: Tensor) -> list[Tensor]: list[Tensor]

Kind: Method

###### get_variants() -> tuple[str, dict[str, VariantParamsDict]]: tuple[str, dict[str, VariantParamsDict]]

Kind: Static Method

###### micronet

Kind: Package

###### blocks

Kind: Module

###### luxonis_train.nodes.backbones.micronet.blocks.MicroBlock(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, out_channels: int, kernel_size: int = 3, stride: int = 1, expand_ratio: tuple [ int , int
] = (2, 2), groups_1: tuple [ int , int ] = (0, 6), groups_2: tuple [ int , int ] = (1, 1), dy_shift: tuple [ int , int , int ] =
(2, 0, 1), reduction_factor: int = 1, init_a: tuple [ float , float ] = (1.0, 1.0), init_b: tuple [ float , float ] = (0.0, 0.0))

Kind: Method

MicroBlock: The basic building block of MicroNet.

This block implements the Micro-Factorized Convolution and
Dynamic Shift-Max activation. It can be configured to use
different combinations of these components based on the network
design.

@type in_channels: int
@param in_channels: Number of input channels.
@type out_channels: int
@param out_channels: Number of output channels.
@type kernel_size: int
@param kernel_size: Size of the convolution kernel. Defaults to
3.
@type stride: int
@param stride: Stride of the convolution. Defaults to 1.
@type expansion_ratios: tuple[int, int]
@param expansion_ratios: Expansion ratios for the intermediate
channels. Defaults to (2, 2).
@type groups_1: tuple[int, int]
@param groups_1: Groups for the first set of convolutions.
Defaults to (0, 6).
@type groups_2: tuple[int, int]
@param groups_2: Groups for the second set of convolutions.
Defaults to (1, 1).
@type use_dynamic_shift: tuple[int, int, int]
@param use_dynamic_shift: Flags to use Dynamic Shift-Max in
different positions. Defaults to (2, 0, 1).
@type reduction_factor: int
@param reduction_factor: Reduction factor for the squeeze-and-
excitation-like operation. Defaults to 1.
@type init_a: tuple[float, float]
@param init_a: Initialization parameters for Dynamic Shift-Max.
Defaults to (1.0, 1.0).
@type init_b: tuple[float, float]
@param init_b: Initialization parameters for Dynamic Shift-Max.
Defaults to (0.0, 0.0).

###### use_residual

Kind: Instance Variable

###### expand_ratio

Kind: Instance Variable

###### layers

Kind: Instance Variable

###### forward(self, inputs: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.backbones.micronet.blocks.ChannelShuffle(torch.nn.Module)

Kind: Class

###### __init__(self, groups: int)

Kind: Method

Shuffle the channels of the input tensor.

This operation is used to mix information between groups after
grouped convolutions.

@type groups: int
@param groups: Number of groups to divide the channels into
before shuffling.

###### groups

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.backbones.micronet.blocks.DYShiftMax(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, out_channels: int, init_a: tuple [ float , float ] = (0.0, 0.0), init_b: tuple [ float ,
float ] = (0.0, 0.0), use_relu: bool = True, groups: int = 6, reduction: int = 4, expansion: bool = False)

Kind: Method

Dynamic Shift-Max activation function.

This module implements the Dynamic Shift-Max operation, which
adaptively fuses and selects channel information based on the
input.

@type in_channels: int
@param in_channels: Number of input channels.
@type out_channels: int
@param out_channels: Number of output channels.
@type init_a: tuple[float, float]
@param init_a: Initial values for the 'a' parameters. Defaults
to (0.0, 0.0).
@type init_b: tuple[float, float]
@param init_b: Initial values for the 'b' parameters. Defaults
to (0.0, 0.0).
@type use_relu: bool
@param use_relu: Whether to use ReLU activation. Defaults to
True.
@type groups: int
@param groups: Number of groups for channel shuffling. Defaults
to 6.
@type reduction: int
@param reduction: Reduction factor for the squeeze operation.
Defaults to 4.
@type expansion: bool
@param expansion: Whether to use expansion in grouping. Defaults
to False.

###### exp

Kind: Instance Variable

###### init_a

Kind: Instance Variable

###### init_b

Kind: Instance Variable

###### out_channels

Kind: Instance Variable

###### avg_pool

Kind: Instance Variable

###### fc

Kind: Instance Variable

###### index

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.backbones.micronet.blocks.SpatialSepConvSF(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, outs: tuple [ int , int ], kernel_size: int, stride: int)

Kind: Method

###### conv

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.backbones.micronet.blocks.Stem(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, stride: int, outs: tuple [ int , int ] = (4, 4))

Kind: Method

###### stem

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.backbones.micronet.blocks.DepthSpatialSepConv(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, expand: tuple [ int , int ], kernel_size: int, stride: int)

Kind: Method

###### conv

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### micronet

Kind: Module

###### luxonis_train.nodes.backbones.micronet.micronet.LayerParamsDict(typing.TypedDict)

Kind: Class

###### out_channels: int

Kind: Class Variable

###### stride: int

Kind: Class Variable

###### kernel_size: int

Kind: Class Variable

###### expand_ratio: tuple[int, int]

Kind: Class Variable

###### groups_1: tuple[int, int]

Kind: Class Variable

###### groups_2: tuple[int, int]

Kind: Class Variable

###### dy_shift: tuple[int, int, int]

Kind: Class Variable

###### reduction_factor: int

Kind: Class Variable

###### luxonis_train.nodes.backbones.micronet.micronet.MicroNetVariantDict(typing.TypedDict)

Kind: Class

###### stem_channels: int

Kind: Class Variable

###### stem_groups: tuple[int, int]

Kind: Class Variable

###### init_a: tuple[float, float]

Kind: Class Variable

###### init_b: tuple[float, float]

Kind: Class Variable

###### out_indices: list[int]

Kind: Class Variable

###### layer_params: list[LayerParamsDict]

Kind: Class Variable

###### luxonis_train.nodes.backbones.micronet.MicroNet(luxonis_train.nodes.base_node.BaseNode)

Kind: Class

MicroNet backbone.

Variants

The variant determines the architecture of the MicroNet backbone. Available variants are:

M1 (default):

stem_channels: 6

stem_groups: (3, 2)

init_a: (1.0, 1.0)

init_b: (0.0, 0.0)

out_indices: [1, 2, 4, 7]

strides: [2, 2, 2, 1, 2, 1, 1]

out_channels: [8, 16, 16, 32, 64, 96, 576]

kernel_sizes: [3, 3, 5, 5, 5, 3, 3]

expand_ratios: [(2, 2), (2, 2), (2, 2), (1, 6), (1, 6), (1, 6), (1, 6)]

groups_1: [(0, 6), (0, 8), (0, 16), (4, 4), (8, 8), (8, 8), (12, 12)]

groups_2: [(2, 2), (4, 4), (4, 4), (4, 4), (8, 9), (8, 8), (0, 0)]

dy_shifts: [(2, 0, 1), (2, 2, 1), (2, 2, 1), (2, 2, 1), (2, 2, 1), (2, 2, 1), (2, 2, 1)]

reduction_factors: [1, 1, 1, 1, 1, 2, 2]

M2:

stem_channels: 8

stem_groups: (4, 2)

init_a: (1.0, 1.0)

init_b: (0.0, 0.0)

out_indices: [1, 3, 6, 9]

strides: [2, 2, 1, 2, 1, 1, 2, 1, 1]

out_channels: [12, 16, 24, 32, 32, 64, 96, 128, 768]

kernel_sizes: [3, 3, 3, 5, 5, 5, 5, 3, 3]

expand_ratios: [(2, 2), (2, 2), (2, 2), (1, 6), ...]

groups_1: [(0, 8), (0, 12), (0, 16), (6, 6), (8, 8), (8, 8), (8, 8), (12, 12), (16, 16)]

groups_2: [(4, 4), (4, 4), (4, 4), (4, 4), (8, 8), (8, 8), (8, 8), (0, 0)]

dy_shifts: [(2, 0, 1), (2, 2, 1), ...]

reduction_factors: [1, 1, 1, 1, 2, 2, 2, 2, 2]

M3:

stem_channels: 12

stem_groups: (4, 3)

init_a: (1.0, 0.5)

init_b: (0.0, 0.5)

out_indices: [1, 3, 8, 12]

strides: [2, 2, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1]

out_channels: [16, 24, 24, 32, 32, 64, 80, 80, 120, 120, 144, 864]

kernel_sizes: [3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 3, 3]

expand_ratios: [(2, 2), (2, 2), (2, 2), (1, 6), ...]

groups_1: [(0, 12), (0, 16), (0, 24), (6, 6), (8, 8), (8, 8), (8, 8), (10, 10), (10, 10), (12, 12), (12, 12), (12, 12)]

groups_2: [(4, 4), (4, 4), (4, 4), (4, 4), (4, 4), (8, 8), (8, 8), (8, 8), (10, 10), (10, 10), (12, 12), (0, 0)]

dy_shifts: [(0, 2, 0), ...]

reduction_factors: [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2]

###### __init__(self, stem_channels: int = 6, stem_groups: tuple [ int , int ] = (3, 2), init_a: tuple [ float , float ] = (1.0,
1.0), init_b: tuple [ float , float ] = (0.0, 0.0), out_indices: list [ int ] | None = None, layer_params: list [ LayerParamsDict
] | None = None, kwargs)

Kind: Method

MicroNet backbone.

This class creates the full MicroNet architecture based on the
specified variant. It consists of a stem layer followed by
multiple MicroBlocks.

@type out_indices: list[int] | None
@param out_indices: Indices of the output layers. If provided,
overrides the variant value.

###### out_indices

Kind: Instance Variable

###### layers

Kind: Instance Variable

###### forward(self, inputs: Tensor) -> list[Tensor]: list[Tensor]

Kind: Method

###### get_variants() -> tuple[str, dict[str, MicroNetVariantDict]]: tuple[str, dict[str, MicroNetVariantDict]]

Kind: Static Method

###### mobilenetv2

Kind: Module

###### mobileone

Kind: Package

###### mobileone

Kind: Module

###### luxonis_train.nodes.backbones.mobileone.MobileOne(luxonis_train.nodes.base_node.BaseNode)

Kind: Class

MobileOne: An efficient CNN backbone for mobile devices.

The architecture focuses on reducing memory access costs and improving parallelism while allowing aggressive parameter scaling for
better representation capacity. Different variants (S0-S4) offer various accuracy-latency tradeoffs.

Key features:

Designed for low latency on mobile while maintaining high accuracy

Uses re-parameterizable branches during training that get folded at inference

Employs trivial over-parameterization branches for improved accuracy

Simple feed-forward structure at inference with no branches/skip connections

Variants achieve <1ms inference time on iPhone 12 with up to 75.9% top-1 ImageNet accuracy

Outperforms other efficient architectures like MobileNets on image classification, object detection and semantic segmentation
tasks

Uses only basic operators available across platforms (no custom activations)

Reference: MobileOne: An Improved One millisecond Mobile Backbone

Source:

Variants

Each variant specifies a predefined set of values for:

width multipliers - A tuple of 4 float values specifying the width multipliers for each stage of the network. If the use of SE
blocks is disabled, the last two values are ignored.

number of convolution branches - An integer specifying the number of linear convolution branches in MobileOne block.

use of SE blocks - A boolean specifying whether to use SE blocks in the network.

Available variants are:

s0 (default): width_multipliers=(0.75, 1.0, 1.0, 2.0), n_conv_branches=4, use_se=False

s1: width_multipliers=(1.5, 1.5, 2.0, 2.5)

s2: width_multipliers=(1.5, 2.0, 2.5, 4.0)

s3: width_multipliers=(2.0, 2.5, 3.0, 4.0)

s4: width_multipliers=(3.0, 3.5, 3.5, 4.0), use_se=True

###### in_channels: int

Kind: Class Variable

###### __init__(self, width_multipliers: tuple [ float , float , float , float ] = (0.75, 1.0, 1.0, 2.0), n_conv_branches: int =
4, use_se: bool = False, kwargs)

Kind: Method

@type width_multipliers: tuple[float, float, float, float]
@param width_multipliers: Width multipliers for each stage.
@type n_conv_branches: int
@param n_conv_branches: Number of linear convolution branches in MobileOne block.
@type use_se: bool
@param use_se: Whether to use C{Squeeze-and-Excitation} blocks in the network. Default is C{False}.

###### n_blocks_per_stage

Kind: Instance Variable

###### n_conv_branches

Kind: Instance Variable

###### stages

Kind: Instance Variable

###### forward(self, inputs: Tensor) -> list[Tensor]: list[Tensor]

Kind: Method

###### get_variants() -> tuple[str, dict[str, Kwargs]]: tuple[str, dict[str, Kwargs]]

Kind: Static Method

###### pplcnet_v3

Kind: Package

###### blocks

Kind: Module

###### luxonis_train.nodes.backbones.pplcnet_v3.blocks.AffineActivation(torch.nn.Module)

Kind: Class

###### __init__(self)

Kind: Method

###### activation

Kind: Instance Variable

###### affine

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.backbones.pplcnet_v3.blocks.AffineBlock(torch.nn.Module)

Kind: Class

###### __init__(self, scale_value: float = 1.0, bias_value: float = 0.0)

Kind: Method

###### scale

Kind: Instance Variable

###### bias

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.backbones.pplcnet_v3.blocks.LCNetV3Block(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int, use_se: bool = False, n_branches: int =
4)

Kind: Method

###### dw_conv

Kind: Instance Variable

###### se

Kind: Instance Variable

###### pw_conv

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.backbones.pplcnet_v3.blocks.LCNetV3Layer(torch.nn.Sequential)

Kind: Class

###### __init__(self, in_channels: int, out_channels: list [ int ], kernel_sizes: list [ int ], strides: list [ int ], use_se:
list [ bool ], n_branches: int = 4, scale: float = 1.0)

Kind: Method

###### in_channels

Kind: Instance Variable

###### out_channels

Kind: Instance Variable

###### scale_up(v: float, scale: float, divisor: int = 16, min_value: int | None = None) -> int: int

Kind: Function

###### pplcnet_v3

Kind: Module

###### luxonis_train.nodes.backbones.pplcnet_v3.pplcnet_v3.LayerParamsDict(typing.TypedDict)

Kind: Class

###### kernel_sizes: list[int]

Kind: Class Variable

###### out_channels: list[int]

Kind: Class Variable

###### strides: list[int]

Kind: Class Variable

###### use_se: list[bool]

Kind: Class Variable

###### luxonis_train.nodes.backbones.pplcnet_v3.pplcnet_v3.PPLCNetVariantDict(typing.TypedDict)

Kind: Class

###### scale: float

Kind: Class Variable

###### n_branches: int

Kind: Class Variable

###### use_detection_backbone: bool

Kind: Class Variable

###### layer_params: list[LayerParamsDict]

Kind: Class Variable

###### luxonis_train.nodes.backbones.pplcnet_v3.PPLCNetV3(luxonis_train.nodes.base_node.BaseNode)

Kind: Class

PPLCNetV3 backbone.

Variants

Only one variant is available, "rec-light".

###### in_channels: int

Kind: Class Variable

###### __init__(self, scale: float, n_branches: int, use_detection_backbone: bool, max_text_len: int, layer_params: list [
LayerParamsDict ] | None = None, kwargs)

Kind: Method

@type scale: float
@param scale: Scale factor. Defaults to 0.95.
@type n_branches: int
@param n_branches: Number of convolution branches.
Defaults to 4.
@type use_detection_backbone: bool
@param use_detection_backbone: Whether to use the detection backbone.
Defaults to False.
@type max_text_len: int
@param max_text_len: Maximum text length. Defaults to 40.

###### scale

Kind: Instance Variable

###### use_detection_backbone

Kind: Instance Variable

###### n_branches

Kind: Instance Variable

###### conv

Kind: Instance Variable

###### blocks

Kind: Instance Variable

###### detecion_blocks

Kind: Instance Variable

###### avg_pool

Kind: Instance Variable

###### forward(self, x: Tensor) -> list[Tensor]: list[Tensor]

Kind: Method

###### get_variants() -> tuple[str, dict[str, PPLCNetVariantDict]]: tuple[str, dict[str, PPLCNetVariantDict]]

Kind: Static Method

###### recsubnet

Kind: Package

###### recsubnet

Kind: Module

###### luxonis_train.nodes.backbones.recsubnet.RecSubNet(luxonis_train.nodes.base_node.BaseNode)

Kind: Class

###### in_channels: int

Kind: Class Variable

###### __init__(self, base_channels: int = 128, width_multipliers: list [ float ] | None = None, out_channels: int = 3, kwargs)

Kind: Method

RecSubNet: A reconstruction sub-network that consists of an
encoder and a decoder.

This model is designed to reconstruct the original image from an input image that contains noise or anomalies.
The encoder extracts relevant features from the noisy input, and the decoder attempts to reconstruct the clean
version of the image by eliminating the noise or anomalies.

This architecture is based on the paper:
"Data-Efficient Image Transformers: A Deeper Look" (https://arxiv.org/abs/2108.07610).

@type out_channels: int
@param out_channels: Number of output channels for the decoder. Defaults to 3.

@type base_channels: int
@param base_channels: The base width of the network.
Determines the number of filters in the encoder and decoder.

@type encoder: nn.Module
@param encoder: The encoder block to use. Defaults to Encoder.

@type decoder: nn.Module
@param decoder: The decoder block to use. Defaults to Decoder.

###### encoder

Kind: Instance Variable

###### decoder

Kind: Instance Variable

###### forward(self, x: Tensor) -> Packet[Tensor]: Packet[Tensor]

Kind: Method

Performs the forward pass through the encoder and decoder.

###### get_variants() -> tuple[str, dict[str, Kwargs]]: tuple[str, dict[str, Kwargs]]

Kind: Static Method

###### repvgg

Kind: Package

###### repvgg

Kind: Module

###### luxonis_train.nodes.backbones.repvgg.RepVGG(luxonis_train.nodes.base_node.BaseNode)

Kind: Class

RepVGG backbone.

Variants

The variant determines the number of blocks in each stage and the width multiplier.

The following variants are available:

"A0" (default): n_blocks=(2, 4, 14, 1), width_multiplier=(0.75, 0.75, 0.75, 2.5)

"A1": n_blocks=(2, 4, 14, 1), width_multiplier=(1, 1, 1, 2.5)

"A2": n_blocks=(2, 4, 14, 1), width_multiplier=(1.5, 1.5, 1.5, 2.75)

###### in_channels: int

Kind: Class Variable

###### __init__(self, n_blocks: tuple [ int , int , int , int ] = (2, 4, 14, 1), width_multiplier: tuple [ float , float , float ,
float ] = (0.75, 0.75, 0.75, 2.5), override_groups_map: dict [ int , int ] | None = None, use_se: bool = False, kwargs)

Kind: Method

RepVGG backbone.

RepVGG is a VGG-style convolutional architecture.

- Simple feed-forward topology without any branching.
- 3x3 convolutions and ReLU activations.
- No automatic search, manual refinement or compound scaling.

@license: U{MIT
<https://github.com/DingXiaoH/RepVGG/blob/main/LICENSE>}.

@see: U{https://github.com/DingXiaoH/RepVGG}
@see: U{https://paperswithcode.com/method/repvgg}
@see: U{RepVGG: Making VGG-style ConvNets Great Again
<https://arxiv.org/abs/2101.03697>}

@type n_blocks: tuple[int, int, int, int]
@param n_blocks: Number of blocks in each stage.
@type width_multiplier: tuple[float, float, float, float]
@param width_multiplier: Width multiplier for each stage.
@type override_groups_map: dict[int, int] | None
@param override_groups_map: Dictionary mapping layer index to number of groups. The layers are indexed starting from 0.
@type use_se: bool
@param use_se: Whether to use Squeeze-and-Excitation blocks.

###### use_se

Kind: Instance Variable

###### stage0

Kind: Instance Variable

###### blocks

Kind: Instance Variable

###### forward(self, inputs: Tensor) -> list[Tensor]: list[Tensor]

Kind: Method

###### get_variants() -> tuple[str, dict[str, Kwargs]]: tuple[str, dict[str, Kwargs]]

Kind: Static Method

###### resnet

Kind: Module

###### rexnetv1

Kind: Module

###### luxonis_train.nodes.backbones.rexnetv1.LinearBottleneck(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, channels: int, t: int, kernel_size: int = 3, stride: int = 1)

Kind: Method

###### use_shortcut

Kind: Instance Variable

###### in_channels

Kind: Instance Variable

###### out_channels

Kind: Instance Variable

###### out

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.backbones.ContextSpatial(luxonis_train.nodes.base_node.BaseNode)

Kind: Class

###### __init__(self, context_backbone: str | nn.Module = 'MobileNetV2', backbone_kwargs: Kwargs | None = None, kwargs)

Kind: Method

Context Spatial backbone introduced in BiseNetV1.

Source: U{BiseNetV1<https://github.com/taveraantonio/BiseNetv1>}

@see: U{BiseNetv1: Bilateral Segmentation Network for
Real-time Semantic Segmentation
<https://arxiv.org/abs/1808.00897>}

@type context_backbone: str
@param context_backbone: Backbone used in the context path.
Can be either a string or a C{nn.Module}.
If a string argument is used, it has to be a name of a module
stored in the L{NODES} registry. Defaults to C{MobileNetV2}.

@type backbone_kwargs: dict
@param backbone_kwargs: Keyword arguments for the backbone.
Only used when the C{context_backbone} argument is a string.

###### context_path

Kind: Instance Variable

###### spatial_path

Kind: Instance Variable

###### ffm

Kind: Instance Variable

###### forward(self, inputs: Tensor) -> list[Tensor]: list[Tensor]

Kind: Method

###### luxonis_train.nodes.backbones.EfficientNet(luxonis_train.nodes.base_node.BaseNode)

Kind: Class

###### __init__(self, out_indices: list [ int ] | None = None, weights: Literal [ ' download ' , ' none ' ] | None = None, kwargs)

Kind: Method

EfficientNet backbone.

EfficientNet is a convolutional neural network architecture and scaling method that uniformly scales all dimensions of
depth/width/resolution using a compound coefficient. Unlike conventional practice that arbitrary scales these factors, the
EfficientNet scaling method uniformly scales network width, depth, and resolution with a set of fixed scaling coefficients.

Source: U{https://github.com/rwightman/gen-efficientnet-pytorch}

@license: U{Apache License, Version 2.0
<https://github.com/rwightman/gen-efficientnet-pytorch/blob/master/LICENSE>}

@see: U{https://paperswithcode.com/method/efficientnet}
@see: U{EfficientNet: Rethinking Model Scaling for
Convolutional Neural Networks
<https://arxiv.org/abs/1905.11946>}
@type out_indices: list[int] | None
@param out_indices: Indices of the output layers. Defaults to [0, 1, 2, 4, 6].

###### backbone

Kind: Instance Variable

###### out_indices

Kind: Instance Variable

###### forward(self, inputs: Tensor) -> list[Tensor]: list[Tensor]

Kind: Method

###### luxonis_train.nodes.backbones.MobileNetV2(luxonis_train.nodes.base_node.BaseNode)

Kind: Class

###### __init__(self, out_indices: list [ int ] | None = None, weights: Literal [ ' download ' , ' none ' ] | None = None, kwargs)

Kind: Method

MobileNetV2 backbone.

This class implements the MobileNetV2 model as described in:
U{MobileNetV2: Inverted Residuals and Linear Bottlenecks <https://arxiv.org/pdf/1801.04381v4>} by Sandler I{et al.}

The network consists of an initial fully convolutional layer, followed by
19 bottleneck residual blocks, and a final 1x1 convolution. It can be used
as a feature extractor for tasks like image classification, object detection,
and semantic segmentation.

Key features:
- Inverted residual structure with linear bottlenecks
- Depth-wise separable convolutions for efficiency
- Configurable width multiplier and input resolution

@type out_indices: list[int] | None
@param out_indices: Indices of the output layers. Defaults to [3, 6, 13, 18].

###### backbone

Kind: Instance Variable

###### out_indices

Kind: Instance Variable

###### forward(self, inputs: Tensor) -> list[Tensor]: list[Tensor]

Kind: Method

###### luxonis_train.nodes.backbones.ResNet(luxonis_train.nodes.base_node.BaseNode)

Kind: Class

###### __init__(self, variant: Literal [ ' 18 ' , ' 34 ' , ' 50 ' , ' 101 ' , ' 152 ' ] = '18', zero_init_residual: bool = False,
groups: int = 1, width_per_group: int = 64, replace_stride_with_dilation: tuple [ bool , bool , bool ] = (False, False, False),
weights: Literal [ ' download ' , ' none ' ] | None = None, kwargs)

Kind: Method

ResNet backbone.

Implements the backbone of a ResNet (Residual Network) architecture.

ResNet is designed to address the vanishing gradient problem in deep neural networks
by introducing skip connections. These connections allow the network to learn
residual functions with reference to the layer inputs, enabling training of much
deeper networks.

This backbone can be used as a feature extractor for various computer vision tasks
such as image classification, object detection, and semantic segmentation. It
provides a robust set of features that can be fine-tuned for specific applications.

The architecture consists of stacked residual blocks, each containing convolutional
layers, batch normalization, and ReLU activations. The skip connections can be
either identity mappings or projections, depending on the block type.

Source: U{https://pytorch.org/vision/main/models/resnet.html}

@license: U{PyTorch<https://github.com/pytorch/pytorch/blob/master/LICENSE>}

@param variant: ResNet variant, determining the depth and structure of the network. Options are:
- "18": 18 layers, uses basic blocks, smaller model suitable for simpler tasks.
- "34": 34 layers, uses basic blocks, good balance of depth and computation.
- "50": 50 layers, introduces bottleneck blocks, deeper feature extraction.
- "101": 101 layers, uses bottleneck blocks, high capacity for complex tasks.
- "152": 152 layers, deepest variant, highest capacity but most computationally intensive.
The number in each variant represents the total number of weighted layers.
Deeper networks generally offer higher accuracy but require more computation.
@type variant: Literal["18", "34", "50", "101", "152"]
@default variant: "18"

@type zero_init_residual: bool
@param zero_init_residual: Zero-initialize the last BN in each residual branch,
so that the residual branch starts with zeros, and each residual block behaves like an identity.
This improves the model by 0.2~0.3% according to U{Accurate, Large Minibatch SGD: Training ImageNet in 1 Hour
<https://arxiv.org/abs/1706.02677>}. Defaults to C{False}.

@type groups: int
@param groups: Number of groups for each block.
Defaults to 1. Can be set to a different value only
for ResNet-50, ResNet-101, and ResNet-152.
The width of the convolutional blocks is computed as
C{int(in_channels * (width_per_group / 64.0)) * groups}

@type width_per_group: int
@param width_per_group: Number of channels per group.
Defaults to 64. Can be set to a different value only
for ResNet-50, ResNet-101, and ResNet-152.
The width of the convolutional blocks is computed as
C{int(in_channels * (width_per_group / 64.0)) * groups}

@type replace_stride_with_dilation: tuple[bool, bool, bool]
@param replace_stride_with_dilation: Tuple of booleans where each
indicates if the 2x2 strides should be replaced with a dilated convolution instead.
Defaults to (False, False, False). Can be set to a different value only for ResNet-50, ResNet-101, and ResNet-152.

###### backbone

Kind: Instance Variable

###### forward(self, inputs: Tensor) -> list[Tensor]: list[Tensor]

Kind: Method

###### get_variants() -> tuple[str, dict[str, Kwargs]]: tuple[str, dict[str, Kwargs]]

Kind: Static Method

###### luxonis_train.nodes.backbones.ReXNetV1_lite(luxonis_train.nodes.base_node.BaseNode)

Kind: Class

###### __init__(self, fix_head_stem: bool = False, divisible_value: int = 8, input_ch: int = 16, final_ch: int = 164, multiplier:
float = 1.0, kernel_sizes: int | list [ int ] = 3, out_indices: list [ int ] | None = None, kwargs)

Kind: Method

ReXNetV1 (Rank Expansion Networks) backbone, lite version.

ReXNet proposes a new approach to designing lightweight CNN architectures by:

- Studying proper channel dimension expansion at the layer level using rank analysis
- Searching for effective channel configurations across the entire network
- Parameterizing channel dimensions as a linear function of network depth

Key aspects:

- Uses inverted bottleneck blocks similar to MobileNetV2
- Employs a linear parameterization of channel dimensions across blocks
- Replaces ReLU6 with SiLU (Swish-1) activation in certain layers
- Incorporates Squeeze-and-Excitation modules

ReXNet achieves state-of-the-art performance among lightweight models on ImageNet
classification and transfers well to tasks like object detection and fine-grained classification.

Source: U{https://github.com/clovaai/rexnet}

@license: U{MIT
<https://github.com/clovaai/rexnet/blob/master/LICENSE>}
@copyright: 2021-present NAVER Corp.
@see U{Rethinking Channel Dimensions for Efficient Model Design <https://arxiv.org/abs/2007.00992>}
@type fix_head_stem: bool
@param fix_head_stem: Whether to multiply head stem. Defaults to False.
@type divisible_value: int
@param divisible_value: Divisor used. Defaults to 8.
@type input_ch: int
@param input_ch: Starting channel dimension. Defaults to 16.
@type final_ch: int
@param final_ch: Final channel dimension. Defaults to 164.
@type multiplier: float
@param multiplier: Channel dimension multiplier. Defaults to 1.0.
@type kernel_sizes: int | list[int]
@param kernel_sizes: Kernel size for each block. Defaults to 3.
@param out_indices: list[int] | None
@param out_indices: Indices of the output layers. Defaults to [1, 4, 10, 17].

###### n_convblocks

Kind: Instance Variable

###### out_indices

Kind: Instance Variable

###### features

Kind: Instance Variable

###### forward(self, inputs: Tensor) -> list[Tensor]: list[Tensor]

Kind: Method

##### base_node

Kind: Module

###### luxonis_train.nodes.base_node.BaseNode(torch.nn.Module, luxonis_train.variants.VariantBase)

Kind: Class

A base class for all model nodes.

This class defines the basic interface for all nodes.

Furthermore, it utilizes automatic registration of defined subclasses to a NODES registry.

Inputs and outputs of nodes are defined as Packets. A Packet is a dictionary of lists of tensors. Each key in the dictionary
represents a different output from the previous node. Input to the node is a list of Packets, output is a single Packet.

When subclassing, the following methods should be implemented:

forward: Forward pass of the module.

Additionally, the following class attributes can be defined:

attach_index: Index of previous output that this node attaches to.

task: An instance of `luxonis_train.tasks.Task` that specifies the task of the node. Usually defined for head nodes.

###### attach_index

Kind: Instance Variable

Index of previous output that this node attaches to. Can be a single integer to specify a single output, a tuple of two or three
integers to specify a range of outputs or "all" to specify all outputs. Defaults to "all". Python indexing conventions apply.

###### task: Task|None

Kind: Class Variable

###### __init__(self, input_shapes: list [ Packet [ Size ] ] | None = None, original_in_shape: Size | None = None,
dataset_metadata: DatasetMetadata | None = None, n_classes: int | None = None, n_keypoints: int | None = None, in_sizes: Size |
list [ Size ] | None = None, remove_on_export: bool = False, export_output_names: list [ str ] | None = None, attach_index:
AttachIndexType | None = None, task_name: str | None = None, weights: str | Literal [ ' download ' , ' yolo ' , ' none ' ] | None
= None)

Kind: Method

Constructor for the C{BaseNode}.

@type input_shapes: list[Packet[Size]] | None
@param input_shapes: List of input shapes for the module.
@type original_in_shape: Size | None
@param original_in_shape: Original input shape of the model.
Some nodes won't function if not provided.
@type dataset_metadata: L{DatasetMetadata} | None
@param dataset_metadata: Metadata of the dataset. Some nodes
won't function if not provided.
@type n_classes: int | None
@param n_classes: Number of classes in the dataset. Provide only
in case C{dataset_metadata} is not provided. Defaults to
None.
@type in_sizes: Size | list[Size] | None
@param in_sizes: List of input sizes for the node. Provide only
in case the C{input_shapes} were not provided.
@type remove_on_export: bool
@param remove_on_export: If set to True, the node will be removed
from the model during export. Defaults to False.
@type export_output_names: list[str] | None
@param export_output_names: List of output names for the export.
@type attach_index: AttachIndexType
@param attach_index: Index of previous output that this node
attaches to. Can be a single integer to specify a single
output, a tuple of two or three integers to specify a range
of outputs or C{"all"} to specify all outputs. Defaults to
"all". Python indexing conventions apply. If provided as a
constructor argument, overrides the class attribute.
@type task_name: str | None
@param task_name: Specifies which task group from the dataset to use
in case the dataset contains multiple tasks. Otherwise, the
task group is inferred from the dataset metadata.

###### task_name

Kind: Instance Variable

###### current_epoch

Kind: Instance Variable

###### __post_init__(self)

Kind: Method

###### initialize_weights(self, method: Literal [ ' yolo ' , ' none ' ] | str | None = None)

Kind: Method

Initializes the weights of the module.

This method should be overridden in subclasses to provide custom
weight initialization.

@type method: str | None
@param method: Method to use for weight initialization. If set
to "yolo", the weights are initialized using the YOLOv5
method. Defaults to None, which does not perform any
initialization.

###### get_variants() -> tuple[str, dict[str, Kwargs]]: tuple[str, dict[str, Kwargs]]

Kind: Static Method

Returns a name of the default varaint and a dictionary of
available model variants with their parameters.

The keys are the variant names, and the values are dictionaries
of parameters which can be used as C{**kwargs} for the
predefined model constructor.

@rtype: tuple[str, dict[str, Params]]
@return: A tuple containing the default variant name and a
dictionary of available variants with their parameters.

###### name

Kind: Property

###### variant

Kind: Property

###### n_keypoints

Kind: Property

Getter for the number of keypoints.

###### n_classes

Kind: Property

Getter for the number of classes.

###### classes

Kind: Property

Getter for the class mappings.

###### class_names

Kind: Property

Getter for the class names.

###### input_shapes

Kind: Property

Getter for the input shapes.

###### original_in_shape

Kind: Property

Getter for the original input shape as [N, H, W].

###### dataset_metadata

Kind: Property

Getter for the dataset metadata.

###### in_sizes

Kind: Property

Simplified getter for the input shapes.

Should work out of the box for most cases where the input_shapes are sufficiently simple. Otherwise, the input_shapes should be
used directly.

In case in_sizes were provided during initialization, they are returned directly.

Example:

>>> input_shapes = [{"features": [Size(64, 128, 128), Size(3, 224, 224)]}]
>>> attach_index = -1
>>> in_sizes = Size(3, 224, 224)

>>> input_shapes = [{"features": [Size(64, 128, 128), Size(3, 224, 224)]}]
>>> attach_index = "all"
>>> in_sizes = [Size(64, 128, 128), Size(3, 224, 224)]

###### in_channels

Kind: Property

Simplified getter for the number of input channels.

Should work out of the box for most cases where the input_shapes are sufficiently simple. Otherwise, the input_shapes should be
used directly. If attach_index is set to "all" or is a slice, returns a list of input channels, otherwise returns a single value.

###### in_height

Kind: Property

Simplified getter for the input height.

Should work out of the box for most cases where the input_shapes are sufficiently simple. Otherwise, the input_shapes should be
used directly.

###### in_width

Kind: Property

Simplified getter for the input width.

Should work out of the box for most cases where the input_shapes are sufficiently simple. Otherwise, the input_shapes should be
used directly.

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

Kind: Method

Returns the URL to the weights of the node.

Subclasses can override this method to provide a URL to support
loading weights from a remote location.

It is possible to use several special placeholders inside the URL:
- C{{github}} - will be replaced with
C{"https://github.com/luxonis/luxonis-train/releases/download/{version}"},
where C{{version}} is the version of used `luxonis-train` library.
- A version tag can be added to use a specific version. e.g. C{{github:v0.3.0}}
- C{{variant}} - will be replaced with the variant of the node.
If the node was not constructed from a variant, an error
is raised.

The file pointed to by the URL should be a C{.ckpt} file
that is directly loadable using C{nn.Module.load_state_dict}.

###### load_checkpoint(self, ckpt: str | dict [ str , Tensor ] | None = None, strict: bool = True)

Kind: Method

Loads checkpoint for the module.

@type ckpt: str | dict[str, Tensor] | None
@param ckpt: Path to local or remote .ckpt file.
@type strict: bool
@param strict: Whether to load weights strictly or not. Defaults
to True.

###### export

Kind: Property

Getter for the export mode.

###### export.setter(self, mode: bool)

Kind: Method

Sets the module to export mode.

###### set_export_mode(self, mode: bool)

Kind: Method

Sets the module to export mode.

@type mode: bool
@param mode: Value to set the export mode to.

###### remove_on_export

Kind: Property

Getter for the remove_on_export attribute.

###### export_output_names

Kind: Property

Getter for the export_output_names attribute.

###### forward(self, inputs: Tensor | list [ Tensor ] | Packet [ Tensor ] | list [ Packet [ Tensor ] ]) ->
Tensor|list[Tensor]|Packet[Tensor]: Tensor|list[Tensor]|Packet[Tensor]

Kind: Method

Forward pass of the module.

@type inputs: Tensor | list[Tensor] | Packet[Tensor] |
list[Packet[Tensor]]
@param inputs: Inputs to the module. Can be either a single
tensor, a list of tensors or a tensor packet.
@rtype: Tensor | list[Tensor] | Packet[Tensor]
@return: Result of the forward pass. Can be either a single
tensor, a list of tensors or a tensor packet.

###### run(self, inputs: list [ Packet [ Tensor ] ]) -> Packet[Tensor]: Packet[Tensor]

Kind: Method

Combines the forward pass with automatic wrapping and
unwrapping of the inputs.

@type inputs: list[Packet[Tensor]]
@param inputs: Inputs to the module.

@rtype: L{Packet}[Tensor]
@return: Outputs of the module as a dictionary of list of tensors:
C{{"features": [Tensor, ...], "segmentation": [Tensor]}}

###### T

Kind: Type Variable

###### get_attached(self, value: list [ T ] | T) -> list[T]|T: list[T]|T

Kind: Method

Gets the attached elements from a list.

This method is used to get the attached elements from a list
based on the C{attach_index} attribute.

@type value: list[T] | T
@param value: List to get the attached elements from. Can be
either a list of tensors or a list of sizes.
@rtype: list[T] | T
@return: Attached elements. If C{attach_index} is set to
C{"all"} or is a slice, returns a list of attached elements.
@raises ValueError: If the C{attach_index} is invalid.

##### blocks

Kind: Package

###### blocks

Kind: Module

###### luxonis_train.nodes.blocks.blocks.PreciseDecoupledBlock(torch.nn.Module)

Kind: Class

###### __call__: Callable[[Tensor], tuple[Tensor, Tensor, Tensor]]

Kind: Class Variable

###### __init__(self, in_channels: int, reg_channels: int, cls_channels: int, n_classes: int, reg_max: int)

Kind: Method

###### classification_branch

Kind: Instance Variable

###### regression_branch

Kind: Instance Variable

###### forward(self, x: Tensor) -> tuple[Tensor, Tensor, Tensor]: tuple[Tensor, Tensor, Tensor]

Kind: Method

###### luxonis_train.nodes.blocks.blocks.BottleRep(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, out_channels: int, module: ModuleFactory = GeneralReparametrizableBlock, weight: bool =
True, kwargs)

Kind: Method

RepVGG bottleneck module.

@type block: Callable[..., nn.Module]
@param block: Block to use. Defaults to
L{GeneralReparametrizableBlock}.
@type in_channels: int
@param in_channels: Number of input channels.
@type out_channels: int
@param out_channels: Number of output channels.
@type weight: bool
@param weight: If using learnable or static shortcut weight.
Defaults to C{True}.
@param kwargs: Additional keyword arguments to be passed to the
module.

###### conv_1

Kind: Instance Variable

###### conv_2

Kind: Instance Variable

###### shortcut

Kind: Instance Variable

###### alpha

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### reparametrizable

Kind: Module

###### luxonis_train.nodes.blocks.reparametrizable.Reparametrizable(torch.nn.Module, abc.ABC)

Kind: Class

An abstract class for reparametrizable modules.

Reparametrizable modules are modules that support reparametrization of their parameters during export.

Reparametrization is usually done to increase the performance of the model during inference by removing unnecessary parameters,
fusing operations, and other methods.

###### reparametrize(self)

Kind: Method

Reparametrizes the module.

This method is typically called before exporting the model.

###### restore(self)

Kind: Method

Restores the module to its original state.

###### resnet

Kind: Module

###### luxonis_train.nodes.blocks.resnet.GenericResidualBlock(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, hidden_channels: int, stride: int, expansion: int, final_relu: bool, block: nn.Module)

Kind: Method

###### block

Kind: Instance Variable

###### shortcut

Kind: Instance Variable

###### final_relu

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### unet

Kind: Module

###### luxonis_train.nodes.blocks.unet.BaseDecoderBlock(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, out_channels: int, conv_in_channels: int, kernel_size: int, use_norm: bool, align_corners:
bool, upsample_mode: Literal [ ' simple_upsample ' , ' conv_upsample ' , ' conv_transpose ' ], n_repeats: int)

Kind: Method

###### up

Kind: Instance Variable

###### conv

Kind: Instance Variable

###### luxonis_train.nodes.blocks.unet.BaseDecoder(torch.nn.Module)

Kind: Class

###### __init__(self, base_width: int, out_channels: int, encoder_width_multipliers: list [ float ], n_convolutions: int, block:
type [ ( SimpleDecoderBlock | UNetDecoderBlock ) ])

Kind: Method

###### blocks

Kind: Instance Variable

###### final_conv

Kind: Instance Variable

###### utils

Kind: Module

###### T

Kind: Type Variable

###### luxonis_train.nodes.blocks.utils.ModuleFactory(typing.Protocol)

Kind: Class

###### __call__(self, in_channels: int, out_channels: int) -> nn.Module: nn.Module

Kind: Method

###### forward_gather(x: Tensor, modules: Iterable [ nn.Module ]) -> list[Tensor]: list[Tensor]

Kind: Function

Sequential forward pass through a list of modules, gathering
intermediate outputs.

@type x: Tensor
@param x: Input tensor.
@type modules: Iterable[nn.Module]
@param modules: List of modules to apply.
@rtype: list[Tensor]
@return: List of intermediate outputs.

###### luxonis_train.nodes.blocks.DFL(torch.nn.Module)

Kind: Class

###### __init__(self, reg_max: int = 16)

Kind: Method

The DFL (Distribution Focal Loss) module processes input
tensors by applying softmax over a specified dimension and
projecting the resulting tensor to produce output logits.

@type reg_max: int
@param reg_max: Maximum number of regression outputs. Defaults
to 16.

###### conv

Kind: Instance Variable

###### softmax

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.blocks.AttentionRefinmentBlock(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, out_channels: int)

Kind: Method

Attention Refinment block adapted from
U{https://github.com/taveraantonio/BiseNetv1}.

@type in_channels: int
@param in_channels: Number of input channels.
@type out_channels: int
@param out_channels: Number of output channels.

###### conv

Kind: Instance Variable

###### attention

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.blocks.BlockRepeater(torch.nn.Sequential)

Kind: Class

###### __init__(self, module: Callable [ ... , nn.Module ], n_repeats: int, kwargs)

Kind: Method

Module which repeats the block n times. First block accepts
in_channels and outputs out_channels while subsequent blocks.

@type module: C{type[nn.Module]}
@param module: Module to repeat.
@type n_repeats: int
@param n_repeats: Number of blocks to repeat. Defaults to C{1}.
@param kwargs: Additional keyword arguments to be passed to the
module.

###### luxonis_train.nodes.blocks.ConvBlock(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, out_channels: int, kernel_size: int | tuple [ int , int ], stride: int | tuple [ int , int
] = 1, padding: int | tuple [ int , int ] | str = 0, dilation: int | tuple [ int , int ] = 1, groups: int = 1, bias: bool = False,
activation: Callable [ [ Tensor ] , Tensor ] | None | bool = True, use_norm: bool = True, norm_momentum: float = 0.1)

Kind: Method

Conv2d + Optional BN + Activation.

@type in_channels: int
@param in_channels: Number of input channels.
@type out_channels: int
@param out_channels: Number of output channels.
@type kernel_size: int
@param kernel_size: Kernel size.
@type stride: int
@param stride: Stride. Defaults to 1.
@type padding: int | str
@param padding: Padding. Defaults to 0.
@type dilation: int
@param dilation: Dilation. Defaults to 1.
@type groups: int
@param groups: Groups. Defaults to 1.
@type bias: bool
@param bias: Whether to use bias. Defaults to False.
@type activation: L{nn.Module} | None | bool
@param activation: Activation function. Defaults to `nn.Relu`
if not explicitly set to C{None} or C{False}.
@type use_norm: bool
@param use_norm: Whether to use batch normalization. Defaults to
True.

###### in_channels

Kind: Instance Variable

###### out_channels

Kind: Instance Variable

###### kernel_size

Kind: Instance Variable

###### stride

Kind: Instance Variable

###### padding

Kind: Instance Variable

###### dilation

Kind: Instance Variable

###### groups

Kind: Instance Variable

###### bias

Kind: Instance Variable

###### conv

Kind: Instance Variable

###### bn

Kind: Instance Variable

###### activation

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.blocks.ConvStack(luxonis_train.nodes.blocks.BlockRepeater)

Kind: Class

###### __init__(self, in_channels: int, out_channels: int, n_repeats: int = 2)

Kind: Method

Stack of ConvBlocks.

@type in_channels: int
@param in_channels: Number of input channels.
@type out_channels: int
@param out_channels: Number of output channels.
@type n_repeats: int
@param n_repeats: Number of ConvBlocks to stack.

###### luxonis_train.nodes.blocks.CSPStackRepBlock(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, out_channels: int, n_blocks: int = 1, e: float = 0.5)

Kind: Method

Module composed of three 1x1 conv layers and a stack of sub-
blocks consisting of two RepVGG blocks with a residual
connection.

@type in_channels: int
@param in_channels: Number of input channels.
@type out_channels: int
@param out_channels: Number of output channels.
@type n_blocks: int
@param n_blocks: Number of blocks to repeat. Defaults to C{1}.
@type e: float
@param e: Factor for number of intermediate channels. Defaults
to C{0.5}.

###### conv_1

Kind: Instance Variable

###### rep_stack

Kind: Instance Variable

###### conv_2

Kind: Instance Variable

###### conv_3

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.blocks.DropPath(torch.nn.Module)

Kind: Class

Drop paths (Stochastic Depth) per sample, when applied in the main path of residual blocks.

Intended usage of this block is as follows:

>>> class ResNetBlock(nn.Module):
... def __init__(self, ..., drop_path_rate: float):
... self.drop_path = DropPath(drop_path_rate)

... def forward(self, x): ... return x + self.drop_path(self.conv_bn_act(x))

###### drop_prob

Kind: Instance Variable

###### scale_by_keep

Kind: Instance Variable

###### __init__(self, drop_prob: float = 0.0, scale_by_keep: bool = True)

Kind: Method

###### drop_path(self, x: Tensor) -> Tensor: Tensor

Kind: Method

Drop paths (Stochastic Depth) per sample when applied in the
main path of residual blocks.

@type x: Tensor
@param x: Input tensor.
@type drop_prob: float
@param drop_prob: Probability of dropping a path. Defaults to
0.0.
@type scale_by_keep: bool
@param scale_by_keep: Whether to scale the output by the keep
probability. Defaults to True.
@return: Tensor with dropped paths based on the provided drop
probability.

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.blocks.EfficientDecoupledBlock(torch.nn.Module)

Kind: Class

###### __call__: Callable[[Tensor], tuple[Tensor, Tensor, Tensor]]

Kind: Class Variable

###### __init__(self, in_channels: int, n_classes: int)

Kind: Method

Efficient Decoupled block used for class and regression
predictions.

@type n_classes: int
@param n_classes: Number of classes.
@type in_channels: int
@param in_channels: Number of input channels.
@type prior_probability: float
@param prior_probability: ???

###### decoder

Kind: Instance Variable

###### class_branch

Kind: Instance Variable

###### regression_branch

Kind: Instance Variable

###### forward(self, x: Tensor) -> tuple[Tensor, Tensor, Tensor]: tuple[Tensor, Tensor, Tensor]

Kind: Method

###### luxonis_train.nodes.blocks.FeatureFusionBlock(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, out_channels: int, reduction: int = 1)

Kind: Method

Feature Fusion block adapted from: U{https://github.com/taveraantonio/BiseNetv1}.

@type in_channels: int
@param in_channels: Number of input channels.
@type out_channels: int
@param out_channels: Number of output channels.
@type reduction: int
@param reduction: Reduction factor. Defaults to C{1}.

###### conv_1x1

Kind: Instance Variable

###### attention

Kind: Instance Variable

###### forward(self, x1: Tensor, x2: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.blocks.GeneralReparametrizableBlock(luxonis_train.nodes.blocks.reparametrizable.Reparametrizable)

Kind: Class

###### __call__: Callable[[Tensor], Tensor]

Kind: Class Variable

###### __init__(self, in_channels: int, out_channels: int, kernel_size: int = 3, stride: int = 1, padding: int = 1, groups: int =
1, n_branches: int = 1, refine_block: nn.Module | Literal [ ' se ' ] | None = None, use_scale_layer: bool = True,
scale_layer_padding: int | tuple [ int , int ] | None = None, activation: nn.Module | None | bool = True)

Kind: Method

GeneralReparametrizableBlock is a basic rep-style block,
including training and deploy status.

@see: U{https://github.com/DingXiaoH/RepVGG/blob/main/repvgg.py}.

@type in_channels: int
@param in_channels: Number of input channels.
@type out_channels: int
@param out_channels: Number of output channels.
@type kernel_size: int
@param kernel_size: Kernel size. Defaults to C{3}.
@type stride: int
@param stride: Stride. Defaults to C{1}.
@type padding: int
@param padding: Padding. Defaults to C{1}.
@type groups: int
@param groups: Groups. Defaults to C{1}.
@type n_branches: int
@param n_branches: Number of convolutional branches.
During reparametrization, the branches are fused to a single
convolutional layer. Defaults to C{1}.
@type refine_block: nn.Module | Literal["se"] | None
@param refine_block: A block to refine the output.
Placed after the convolutional branches and before the
activation function.
Can be one of the following:
- torch module
- string `"se"` which will use L{SqueezeExciteBlock}
- None for no operation
Defaults to C{None}.
@type activation: nn.Module | None | bool
@param activation: Activation function. By default C{nn.ReLU}.
If C{False} or C{None} then no activation.

###### in_channels

Kind: Instance Variable

###### out_channels

Kind: Instance Variable

###### kernel_size

Kind: Instance Variable

###### groups

Kind: Instance Variable

###### skip_layer

Kind: Instance Variable

###### scale_layer

Kind: Instance Variable

###### refine_block

Kind: Instance Variable

###### activation

Kind: Instance Variable

###### branches

Kind: Instance Variable

###### fused_branch

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### name

Kind: Property

###### reparametrize(self)

Kind: Method

###### restore(self)

Kind: Method

###### luxonis_train.nodes.blocks.SegProto(torch.nn.Sequential)

Kind: Class

###### __init__(self, in_channels: int, mid_channels: int = 256, out_channels: int = 32)

Kind: Method

Initializes the segmentation prototype generator.

@type in_channels: int
@param in_channels: Number of input channels.
@type mid_channels: int
@param mid_channels: Number of intermediate channels. Defaults
to 256.
@type out_channels: int
@param out_channels: Number of output channels. Defaults to 32.

###### luxonis_train.nodes.blocks.SpatialPyramidPoolingBlock(torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, out_channels: int, kernel_size: int = 5)

Kind: Method

Spatial Pyramid Pooling block with ReLU activation on three
different scales.

@type in_channels: int
@param in_channels: Number of input channels.
@type out_channels: int
@param out_channels: Number of output channels.
@type kernel_size: int
@param kernel_size: Kernel size. Defaults to C{5}.

###### conv1

Kind: Instance Variable

###### conv2

Kind: Instance Variable

###### max_pool

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.blocks.SqueezeExciteBlock(torch.nn.Sequential)

Kind: Class

###### __init__(self, in_channels: int, intermediate_channels: int, hard_sigmoid: bool = False, activation: nn.Module | None =
None)

Kind: Method

Squeeze and Excite block,
Adapted from U{Squeeze-and-Excitation Networks<https://arxiv.org/pdf/1709.01507.pdf>}.
Code adapted from U{https://github.com/apple/ml-mobileone/blob/main/mobileone.py}.

@type in_channels: int
@param in_channels: Number of input channels.
@type intermediate_channels: int
@param intermediate_channels: Number of intermediate channels.
@type hard_sigmoid: bool
@param hard_sigmoid: Whether to use hard sigmoid function. Defaults to False.
@type activation: L{nn.Module} | None
@param activation: Activation function. Defaults to L{nn.ReLU}.

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.blocks.UpscaleOnline(torch.nn.Module)

Kind: Class

Upscale tensor to a specified size during the forward pass.

This class supports cases where the required scale/size is only known when the input is received. Only the interpolation mode is
set in advance.

###### mode

Kind: Instance Variable

###### __init__(self, mode: str = 'bilinear')

Kind: Method

###### forward(self, x: Tensor, output_height: int, output_width: int) -> Tensor: Tensor

Kind: Method

Upscale the input tensor to the specified height and width.

@type x: Tensor
@param x: Input tensor to be upscaled.
@type output_height: int
@param output_height: Desired height of the output tensor.
@type output_width: int
@param output_width: Desired width of the output tensor.
@return: Upscaled tensor.

###### autopad(kernel_size: T, padding: T | None = None) -> T: T

Kind: Function

Compute padding based on kernel size.

@type kernel_size: int | tuple[int, ...]
@param kernel_size: Kernel size.
@type padding: int | tuple[int, ...] | None
@param padding: Padding. Defaults to None.

@rtype: int | tuple[int, ...]
@return: Computed padding. The output type is the same as the type of the
C{kernel_size}.

###### luxonis_train.nodes.blocks.ResNetBlock(luxonis_train.nodes.blocks.resnet.GenericResidualBlock)

Kind: Class

###### __init__(self, in_channels: int, hidden_channels: int, stride: int = 1, expansion: int = 1, final_relu: bool = True,
droppath_prob: float = 0.0)

Kind: Method

A basic residual block for ResNet.

@type in_channels: int
@param in_channels: Number of input channels.
@type hidden_channels: int
@param hidden_channels: Number of output channels.
@type stride: int
@param stride: Stride for the convolutional layers. Defaults to 1.
@type expansion: int
@param expansion: Expansion factor for the output channels. Defaults to 1.
@type final_relu: bool
@param final_relu: Whether to apply a ReLU activation after the residual
addition. Defaults to True.
@type droppath_prob: float
@param droppath_prob: Drop path probability for stochastic depth. Defaults to
0.0.

###### luxonis_train.nodes.blocks.ResNetBottleneck(luxonis_train.nodes.blocks.resnet.GenericResidualBlock)

Kind: Class

###### __init__(self, in_channels: int, hidden_channels: int, stride: int = 1, expansion: int = 4, final_relu: bool = True,
droppath_prob: float = 0.0)

Kind: Method

A bottleneck block for ResNet.

@type in_channels: int
@param in_channels: Number of input channels.
@type hidden_channels: int
@param hidden_channels: Number of intermediate channels.
@type stride: int
@param stride: Stride for the second convolutional layer. Defaults to 1.
@type expansion: int
@param expansion: Expansion factor for the output channels. Defaults to 4.
@type final_relu: bool
@param final_relu: Whether to apply a ReLU activation after the residual
addition. Defaults to True.
@type droppath_prob: float
@param droppath_prob: Drop path probability for stochastic depth. Defaults to
0.0.

###### luxonis_train.nodes.blocks.EncoderBlock(torch.nn.Sequential)

Kind: Class

###### __init__(self, in_channels: int, out_channels: int, n_repeats: int, max_pool: bool = True)

Kind: Method

###### luxonis_train.nodes.blocks.SimpleDecoder(luxonis_train.nodes.blocks.unet.BaseDecoder)

Kind: Class

###### __init__(self, base_width: int, out_channels: int, encoder_width_multipliers: list [ float ], n_convolutions: int = 2)

Kind: Method

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.blocks.SimpleDecoderBlock(luxonis_train.nodes.blocks.unet.BaseDecoderBlock)

Kind: Class

###### __init__(self, in_channels: int, out_channels: int, kernel_size: int, use_norm: bool, align_corners: bool, upsample_mode:
Literal [ ' simple_upsample ' , ' conv_upsample ' , ' conv_transpose ' ], n_repeats: int)

Kind: Method

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.blocks.SimpleEncoder(torch.nn.Sequential)

Kind: Class

###### __init__(self, in_channels: int, base_hidden_channels: int, width_multipliers: list [ float ], n_convolutions: int = 2)

Kind: Method

###### luxonis_train.nodes.blocks.UNetDecoder(luxonis_train.nodes.blocks.unet.BaseDecoder)

Kind: Class

###### __init__(self, base_width: int, out_channels: int, encoder_width_multipliers: list [ float ], n_convolutions: int = 2)

Kind: Method

###### forward(self, inputs: list [ Tensor ]) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.blocks.UNetDecoderBlock(luxonis_train.nodes.blocks.unet.BaseDecoderBlock)

Kind: Class

###### __init__(self, in_channels: int, out_channels: int, kernel_size: int, use_norm: bool, align_corners: bool, upsample_mode:
Literal [ ' simple_upsample ' , ' conv_upsample ' , ' conv_transpose ' ], n_repeats: int)

Kind: Method

###### forward(self, x: Tensor, skip_x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.blocks.UNetEncoder(luxonis_train.nodes.blocks.SimpleEncoder)

Kind: Class

###### forward(self, x: Tensor) -> list[Tensor]: list[Tensor]

Kind: Method

###### luxonis_train.nodes.blocks.UpBlock(torch.nn.Sequential)

Kind: Class

###### __init__(self, in_channels: int, out_channels: int, upsample_mode: Literal [ ' simple_upsample ' , ' conv_upsample ' , '
conv_transpose ' ], kernel_size: int, use_norm: bool, align_corners: bool, stride: int = 2, activation: nn.Module | None | bool =
True, interpolation_mode: Literal [ ' nearest ' , ' linear ' , ' bilinear ' , ' bicubic ' , ' trilinear ' ] = 'bilinear')

Kind: Method

Upsampling with ConvTranspose2D or Upsample (based on the
mode).

@type in_channels: int
@param in_channels: Number of input channels.
@type out_channels: int
@param out_channels: Number of output channels.
@type kernel_size: int
@param kernel_size: Kernel size. Defaults to C{2}.
@type stride: int
@param stride: Stride. Defaults to C{2}.
@type upsample_mode: Literal["simple_upsample", "conv_upsample",
"conv_transpose"]
@param upsample_mode: Upsampling method, either 'conv_transpose'
(for ConvTranspose2D) or one of 'simple_upsample' or
'conv_upsample' (for nn.Upsample). 'conv_upsample' adds an
additional 1x1 convolution after calling nn.Upsample.
@type inter_mode: str
@param inter_mode: Interpolation mode used for nn.Upsample
(e.g., 'bilinear', 'nearest').
@type align_corners: bool
@param align_corners: Align corners option for upsampling
methods that support it. Defaults to False.

##### heads

Kind: Package

###### base_detection_head

Kind: Module

###### luxonis_train.nodes.heads.base_detection_head.BaseDetectionHead(luxonis_train.nodes.heads.BaseHead)

Kind: Class

###### parser

Kind: Instance Variable

###### in_channels: list[int]

Kind: Class Variable

###### in_sizes: list[Size]

Kind: Class Variable

###### __init__(self, n_heads: int, conf_thres: float, iou_thres: float, max_det: int, kwargs)

Kind: Method

Base class for YOLO-like multi-head instance detection heads.

@type n_heads: int
@param n_heads: Number of output heads.
@type conf_thres: float
@param conf_thres: Confidence threshold for NMS.
@type iou_thres: float
@param iou_thres: IoU threshold for NMS.
@type max_det: int
@param max_det: Maximum number of detections retained after NMS.

###### n_heads

Kind: Instance Variable

###### conf_thres

Kind: Instance Variable

###### iou_thres

Kind: Instance Variable

###### max_det

Kind: Instance Variable

###### attach_index

Kind: Instance Variable

###### stride

Kind: Instance Variable

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

Kind: Method

Returns custom head configuration.

@rtype: dict[str, Any]
@return: Custom head configuration.

###### get_output_names(self, default: list [ str ]) -> list[str]: list[str]

Kind: Method

###### fit_stride_to_heads(self) -> Tensor: Tensor

Kind: Method

###### base_head

Kind: Module

###### bisenet_head

Kind: Module

###### classification_head

Kind: Module

###### ddrnet_segmentation_head

Kind: Module

###### discsubnet_head

Kind: Package

###### discsubnet_head

Kind: Module

###### luxonis_train.nodes.heads.discsubnet_head.DiscSubNetHead(luxonis_train.nodes.heads.BaseHead)

Kind: Class

###### in_channels: int

Kind: Class Variable

###### base_channels: int

Kind: Class Variable

###### attach_index

Kind: Instance Variable

###### __init__(self, base_channels: int, width_multipliers: list [ float ], out_channels: int = 2, kwargs)

Kind: Method

DiscSubNetHead: A discriminative sub-network that detects and
segments anomalies in images.

This model is designed to take an input image and generate a
mask that highlights anomalies or regions of interest based on
reconstruction. The encoder extracts relevant features from the
input, while the decoder generates a mask that identifies areas
of anomalies by distinguishing between the reconstructed image
and the input.

@type out_channels: int
@param out_channels: Number of output channels for the decoder.
Defaults to 2 (for segmentation masks).

@type base_channels: int
@param base_channels: The base number of filters used in the encoder and decoder blocks. If None, it is determined based on the
variant.

###### encoder_segment

Kind: Instance Variable

###### decoder_segment

Kind: Instance Variable

###### forward(self, reconstruction: Tensor, original: Tensor) -> Packet[Tensor]: Packet[Tensor]

Kind: Method

Performs the forward pass through the encoder and decoder.

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

Kind: Method

Returns custom head configuration.

@rtype: dict
@return: Custom head configuration.

###### get_variants() -> tuple[str, dict[str, Kwargs]]: tuple[str, dict[str, Kwargs]]

Kind: Static Method

###### efficient_bbox_head

Kind: Module

###### efficient_keypoint_bbox_head

Kind: Module

###### fomo_head

Kind: Module

###### ghostfacenet_head

Kind: Module

###### ocr_ctc_head

Kind: Module

###### precision_bbox_head

Kind: Module

###### precision_seg_bbox_head

Kind: Module

###### refine_and_apply_masks(mask_prototypes: Tensor, predicted_masks: Tensor, bounding_boxes: Tensor, height: int, width: int,
upsample: bool = False) -> Tensor: Tensor

Kind: Function

Refine and apply masks to bounding boxes based on the mask head
outputs.

@type mask_prototypes: Tensor
@param mask_prototypes: Tensor of shape [mask_dim, mask_height,
mask_width].
@type predicted_masks: Tensor
@param predicted_masks: Tensor of shape [n_masks, mask_dim], where
n_masks is the number of detected masks.
@type bounding_boxes: Tensor
@param bounding_boxes: Tensor of shape [n_masks, 4], containing
bounding box coordinates.
@type height: int
@param height: Height of the input image.
@type width: int
@param width: Width of the input image.
@type upsample: bool
@param upsample: If True, upsample the masks to the target image
dimensions. Default is False.
@rtype: Tensor
@return: A binary mask tensor of shape [n_masks, height, width],
where the masks are cropped according to their respective
bounding boxes.

###### segmentation_head

Kind: Module

###### transformer_classification_head

Kind: Module

###### transformer_segmentation_head

Kind: Module

###### luxonis_train.nodes.heads.BaseHead(luxonis_train.nodes.base_node.BaseNode)

Kind: Class

Base class for all heads in the model.

###### parser

Kind: Instance Variable

Parser to use for the head.

###### task: Task

Kind: Class Variable

###### get_head_config(self) -> dict[str, Any]: dict[str, Any]

Kind: Method

Get head configuration.

@rtype: dict
@return: Head configuration.

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

Kind: Method

Get custom head configuration.

@rtype: dict
@return: Custom head configuration.

###### annotate(self, head_output: Packet [ Tensor ], image_paths: list [ Path ], config_preprocessing: PreprocessingConfig) ->
DatasetIterator: DatasetIterator

Kind: Method

Convert head output to a DatasetIterator for dataset annotation. Data should be in standard
U{luxonis-ml record format <https://github.com/luxonis/luxonis-ml/blob/main/luxonis_ml/data/README.md>}.

@type head_output: Packet[Tensor]
@param head_output: Raw outputs from this head.
@type image_paths: list[Path]
@param image_paths: List of original image file paths to annotate.
@type config_preprocessing: PreprocessingConfig
@param config_preprocessing: Config containing train_image_size, keep_aspect_ratio, etc.
@rtype: DatasetIterator
@return: Iterator yielding annotation records in luxonis-ml format.

###### luxonis_train.nodes.heads.BiSeNetHead(luxonis_train.nodes.heads.BaseHead)

Kind: Class

###### in_height: int

Kind: Class Variable

###### in_width: int

Kind: Class Variable

###### in_channels: int

Kind: Class Variable

###### parser

Kind: Instance Variable

###### __init__(self, intermediate_channels: int = 64, kwargs)

Kind: Method

BiSeNet segmentation head.

Source: U{BiseNetV1<https://github.com/taveraantonio/BiseNetv1>}
@license: NOT SPECIFIED.
@see: U{BiseNetv1: Bilateral Segmentation Network for
Real-time Semantic Segmentation
<https://arxiv.org/abs/1808.00897>}

@type intermediate_channels: int
@param intermediate_channels: How many intermediate channels to use.
Defaults to C{64}.

###### conv_3x3

Kind: Instance Variable

###### conv_1x1

Kind: Instance Variable

###### upscale

Kind: Instance Variable

###### forward(self, inputs: Tensor) -> Tensor: Tensor

Kind: Method

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

Kind: Method

Returns custom head configuration.

@rtype: dict
@return: Custom head configuration.

###### luxonis_train.nodes.heads.ClassificationHead(luxonis_train.nodes.heads.BaseHead)

Kind: Class

###### in_channels: int

Kind: Class Variable

###### parser

Kind: Instance Variable

###### __init__(self, dropout_rate: float = 0.2, kwargs)

Kind: Method

Simple classification head.

Consists of a global average pooling layer followed by a dropout
layer and a single linear layer.

@type dropout_rate: float
@param dropout_rate: Dropout rate before last layer, range C{[0,
1]}. Defaults to C{0.2}.

###### head

Kind: Instance Variable

###### forward(self, inputs: Tensor) -> Tensor: Tensor

Kind: Method

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

Kind: Method

Returns custom head configuration.

@rtype: dict
@return: Custom head configuration.

###### luxonis_train.nodes.heads.DDRNetSegmentationHead(luxonis_train.nodes.heads.BaseHead)

Kind: Class

###### in_height: int

Kind: Class Variable

###### in_width: int

Kind: Class Variable

###### in_channels: int

Kind: Class Variable

###### parser

Kind: Instance Variable

###### __init__(self, inter_channels: int = 64, inter_mode: Literal [ ' nearest ' , ' linear ' , ' bilinear ' , ' bicubic ' , '
trilinear ' , ' area ' , ' pixel_shuffle ' ] = 'bilinear', kwargs)

Kind: Method

DDRNet segmentation head.

@see: U{Adapted from <https://github.com/Deci-AI/super-gradients/blob/master/src
/super_gradients/training/models/segmentation_models/ddrnet.py>}
@see: U{Original code <https://github.com/ydhongHIT/DDRNet>}
@see: U{Paper <https://arxiv.org/pdf/2101.06085.pdf>}
@license: U{Apache License, Version 2.0 <https://github.com/Deci-AI/super-
gradients/blob/master/LICENSE.md>}
@type inter_channels: int
@param inter_channels: Width of internal conv. Must be a multiple of
scale_factor^2 when inter_mode is pixel_shuffle. Defaults to 64.
@type inter_mode: str
@param inter_mode: Upsampling method. One of nearest, linear, bilinear, bicubic,
trilinear, area or pixel_shuffle. If pixel_shuffle is set, nn.PixelShuffle
is used for scaling. Defaults to "bilinear".

###### scale_factor

Kind: Instance Variable

###### bn1

Kind: Instance Variable

###### conv1

Kind: Instance Variable

###### bn2

Kind: Instance Variable

###### relu

Kind: Instance Variable

###### conv2

Kind: Instance Variable

###### upscale

Kind: Instance Variable

###### load_checkpoint(self, path: str | None = None, strict: bool = False)

Kind: Method

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

Kind: Method

###### forward(self, inputs: Tensor) -> Tensor: Tensor

Kind: Method

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

Kind: Method

Returns custom head configuration.

@rtype: dict
@return: Custom head configuration.

###### luxonis_train.nodes.heads.EfficientBBoxHead(luxonis_train.nodes.heads.base_detection_head.BaseDetectionHead)

Kind: Class

###### __init__(self, n_heads: Literal [ 2 , 3 , 4 ] = 3, conf_thres: float = 0.25, iou_thres: float = 0.45, max_det: int = 300,
bias_init_p: float = 0.01, kwargs)

Kind: Method

Head for object detection.

Adapted from U{YOLOv6: A Single-Stage Object Detection Framework
for Industrial Applications
<https://arxiv.org/pdf/2209.02976.pdf>}.
@type n_heads: Literal[2,3,4]
@param n_heads: Number of output heads. Defaults to 3. B{Note:}
Should be same also on neck in most cases.
@type conf_thres: float
@param conf_thres: Threshold for confidence. Defaults to
C{0.25}.
@type iou_thres: float
@param iou_thres: Threshold for IoU. Defaults to C{0.45}.
@type max_det: int
@param max_det: Maximum number of detections retained after NMS.
Defaults to C{300}.

###### grid_cell_offset

Kind: Instance Variable

###### grid_cell_size

Kind: Instance Variable

###### heads

Kind: Instance Variable

###### bias_init_p

Kind: Instance Variable

###### initialize_weights(self, method: str | None = None)

Kind: Method

###### load_checkpoint(self, path: str | None = None, strict: bool = False)

Kind: Method

###### forward(self, inputs: list [ Tensor ]) -> Packet[Tensor]: Packet[Tensor]

Kind: Method

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

Kind: Method

###### export_output_names

Kind: Property

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

Kind: Method

Returns custom head configuration.

@rtype: dict
@return: Custom head configuration.

###### luxonis_train.nodes.heads.EfficientKeypointBBoxHead(luxonis_train.nodes.heads.EfficientBBoxHead)

Kind: Class

###### parser

Kind: Instance Variable

###### __init__(self, n_heads: Literal [ 2 , 3 , 4 ] = 3, conf_thres: float = 0.25, iou_thres: float = 0.45, max_det: int = 300,
kwargs)

Kind: Method

Head for object and keypoint detection.

Adapted from U{YOLOv6: A Single-Stage Object Detection Framework for Industrial
Applications<https://arxiv.org/pdf/2209.02976.pdf>}.

@param n_heads: Number of output heads. Defaults to C{3}.
B{Note:} Should be same also on neck in most cases.
@type n_heads: int

@param conf_thres: Threshold for confidence. Defaults to C{0.25}.
@type conf_thres: float

@param iou_thres: Threshold for IoU. Defaults to C{0.45}.
@type iou_thres: float

@param max_det: Maximum number of detections retained after NMS. Defaults to C{300}.
@type max_det: int

###### n_keypoints_flat

Kind: Instance Variable

###### keypoint_heads

Kind: Instance Variable

###### forward(self, inputs: list [ Tensor ]) -> Packet[Tensor]: Packet[Tensor]

Kind: Method

###### export_output_names

Kind: Property

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

Kind: Method

Returns custom head configuration.

@rtype: dict
@return: Custom head configuration.

###### luxonis_train.nodes.heads.FOMOHead(luxonis_train.nodes.heads.BaseHead)

Kind: Class

###### attach_index

Kind: Instance Variable

###### in_channels: int

Kind: Class Variable

###### __init__(self, n_conv_layers: int = 3, conv_channels: int = 16, use_nms: bool = True, kwargs)

Kind: Method

FOMO Head for object detection using heatmaps.

@type n_conv_layers: int
@param n_conv_layers: Number of convolutional layers to use.
@type conv_channels: int
@param conv_channels: Number of channels to use in the
convolutional layers.

###### n_conv_layers

Kind: Instance Variable

###### conv_channels

Kind: Instance Variable

###### use_nms

Kind: Instance Variable

###### conv_layers

Kind: Instance Variable

###### n_keypoints

Kind: Property

###### forward(self, inputs: Tensor) -> Packet[Tensor]: Packet[Tensor]

Kind: Method

###### luxonis_train.nodes.heads.GhostFaceNetHead(luxonis_train.nodes.heads.BaseHead)

Kind: Class

###### in_channels: int

Kind: Class Variable

###### in_width: int

Kind: Class Variable

###### __init__(self, embedding_size: int = 512, cross_batch_memory_size: int | None = None, dropout: float = 0.2, kwargs)

Kind: Method

GhostFaceNet backbone.

GhostFaceNet is a convolutional neural network architecture focused on face recognition, but it is
adaptable to generic embedding tasks. It is based on the GhostNet architecture and uses Ghost BottleneckV2 blocks.

Source: U{https://github.com/Hazqeel09/ellzaf_ml/blob/main/ellzaf_ml/models/ghostfacenetsv2.py}

@license: U{MIT License
<https://github.com/Hazqeel09/ellzaf_ml/blob/main/LICENSE>}

@see: U{GhostFaceNets: Lightweight Face Recognition Model From Cheap Operations
<https://www.researchgate.net/publication/369930264_GhostFaceNets_Lightweight_Face_Recognition_Model_from_Cheap_Operations>}

@type embedding_size: int
@param embedding_size: Size of the embedding. Defaults to 512.
@type cross_batch_memory_size: int | None
@param cross_batch_memory_size: Size of the cross-batch memory. Defaults to None.
@type dropout: float
@param dropout: Dropout rate. Defaults to 0.2.

###### embedding_size

Kind: Instance Variable

###### cross_batch_memory_size

Kind: Instance Variable

###### head

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### initialize_weights(self, method: str | None = None)

Kind: Method

###### luxonis_train.nodes.heads.OCRCTCHead(luxonis_train.nodes.heads.BaseHead)

Kind: Class

###### in_channels: int

Kind: Class Variable

###### parser

Kind: Instance Variable

###### __init__(self, alphabet: list [ str ], ignore_unknown: bool = True, fc_decay: float = 0.0004, mid_channels: int | None =
None, return_feats: bool = False, kwargs)

Kind: Method

OCR CTC head.

@see: U{Adapted from <https://github.com/PaddlePaddle/PaddleOCR/
blob/main/ppocr/modeling/heads/rec_ctc_head.py>}
@see: U{Original code
<https://github.com/PaddlePaddle/PaddleOCR>}
@license: U{Apache License, Version 2.0
<https://github.com/PaddlePaddle/PaddleOCR/blob/main/LICENSE
>}
@type alphabet: list[str]
@param alphabet: List of characters.
@type ignore_unknown: bool
@param ignore_unknown: Whether to ignore unknown characters.
Defaults to True.
@type fc_decay: float
@param fc_decay: L2 regularization factor. Defaults to 0.0004.
@type mid_channels: int
@param mid_channels: Number of middle channels. Defaults to
None.
@type return_feats: bool
@param return_feats: Whether to return features. Defaults to
False.

###### return_feats

Kind: Instance Variable

###### fc_decay

Kind: Instance Variable

###### block

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### encoder

Kind: Property

Returns the OCR encoder.

###### decoder

Kind: Property

Returns the OCR decoder.

###### export_output_names

Kind: Property

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

Kind: Method

Returns custom head configuration.

@rtype: dict
@return: Custom head configuration.

###### out_channels

Kind: Property

###### initialize_weights(self, method: str | None = None)

Kind: Method

###### luxonis_train.nodes.heads.PrecisionBBoxHead(luxonis_train.nodes.heads.base_detection_head.BaseDetectionHead)

Kind: Class

###### __init__(self, n_heads: Literal [ 2 , 3 , 4 ] = 3, conf_thres: float = 0.25, iou_thres: float = 0.45, max_det: int = 300,
reg_max: int = 16, kwargs)

Kind: Method

Adapted from U{Real-Time Flying Object Detection with YOLOv8
<https://arxiv.org/pdf/2305.09972>} and from U{YOLOv6: A Single-Stage Object Detection Framework
for Industrial Applications
<https://arxiv.org/pdf/2209.02976.pdf>}.

@type n_heads: Literal[2, 3, 4]
@param n_heads: Number of output heads.
@type conf_thres: float
@param conf_thres: Confidence threshold for NMS.
@type iou_thres: float
@param iou_thres: IoU threshold for NMS.
@type max_det: int
@param max_det: Maximum number of detections retained after NMS.
@type reg_max: int
@param reg_max: Maximum number of regression channels.

###### reg_max

Kind: Instance Variable

###### no

Kind: Instance Variable

###### grid_cell_offset

Kind: Instance Variable

###### grid_cell_size

Kind: Instance Variable

###### heads

Kind: Instance Variable

###### dfl

Kind: Instance Variable

###### forward_heads(self, inputs: list [ Tensor ]) -> tuple[list[Tensor], list[Tensor], list[Tensor]]: tuple[list[Tensor],
list[Tensor], list[Tensor]]

Kind: Method

###### forward(self, inputs: list [ Tensor ]) -> Packet[Tensor]: Packet[Tensor]

Kind: Method

###### initialize_weights(self, method: str | None = None)

Kind: Method

Initialize biases for the detection heads.

Assumes detection_heads structure with separate regression and
classification branches.

###### export_output_names

Kind: Property

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

Kind: Method

Returns custom head configuration.

@rtype: dict
@return: Custom head configuration.

###### luxonis_train.nodes.heads.PrecisionSegmentBBoxHead(luxonis_train.nodes.heads.PrecisionBBoxHead)

Kind: Class

###### parser

Kind: Instance Variable

###### __init__(self, n_heads: Literal [ 2 , 3 , 4 ] = 3, n_masks: int = 32, n_proto: int = 64, conf_thres: float = 0.25,
iou_thres: float = 0.45, max_det: int = 300, kwargs)

Kind: Method

Head for instance segmentation and object detection.
Adapted from U{Real-Time Flying Object Detection with YOLOv8
<https://arxiv.org/pdf/2305.09972>} and from U{YOLOv6: A Single-Stage Object Detection Framework
for Industrial Applications
<https://arxiv.org/pdf/2209.02976.pdf>}.

@type n_heads: Literal[2, 3, 4]
@param n_heads: Number of output heads. Defaults to 3.
@type n_masks: int
@param n_masks: Number of masks.
@type n_proto: int
@param n_proto: Number of prototypes for segmentation.
@type conf_thres: flaot
@param conf_thres: Confidence threshold for NMS.
@type iou_thres: float
@param iou_thres: IoU threshold for NMS.
@type max_det: int
@param max_det: Maximum number of detections retained after NMS.

###### segmentation_heads

Kind: Instance Variable

###### proto

Kind: Instance Variable

###### n_masks

Kind: Instance Variable

###### forward(self, inputs: list [ Tensor ]) -> Packet[Tensor]: Packet[Tensor]

Kind: Method

###### export_output_names

Kind: Property

###### luxonis_train.nodes.heads.SegmentationHead(luxonis_train.nodes.heads.BaseHead)

Kind: Class

###### in_height: int

Kind: Class Variable

###### in_width: int

Kind: Class Variable

###### in_channels: int

Kind: Class Variable

###### parser

Kind: Instance Variable

###### __init__(self, kwargs: Any)

Kind: Method

Basic segmentation FCN head.

Adapted from: U{https://github.com/pytorch/vision/blob/main/torchvision/models/segmentation/fcn.py}
@license: U{BSD-3 <https://github.com/pytorch/vision/blob/main/LICENSE>}

###### head

Kind: Instance Variable

###### forward(self, inputs: Tensor) -> Tensor: Tensor

Kind: Method

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

Kind: Method

Returns custom head configuration.

@rtype: dict
@return: Custom head configuration.

###### luxonis_train.nodes.heads.TransformerClassificationHead(luxonis_train.nodes.heads.BaseHead)

Kind: Class

Classification decoder head for CLS token output from DINOv3.

Converts [B, C] (CLS token embedding) to [B, n_classes].

###### attach_index

Kind: Instance Variable

###### parser

Kind: Instance Variable

###### __init__(self, dropout_rate: float = 0.2, kwargs)

Kind: Method

Classification head for transformer CLS tokens.

@param dropout_rate: Dropout rate before last layer.

###### dropout

Kind: Instance Variable

###### fc

Kind: Instance Variable

###### in_channels

Kind: Property

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

@param x: CLS tensor in the form [B, C], where C is the embedding dim.
@type x: Tensor
@return: Class logits [B, n_classes]

@note: Steps performed:
1) Apply dropout to the CLS token.
2) Apply a linear layer to produce class logits.

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

Kind: Method

Returns custom head configuration.

@rtype: dict
@return: Custom head configuration.

###### luxonis_train.nodes.heads.TransformerSegmentationHead(luxonis_train.nodes.heads.BaseHead)

Kind: Class

Semantic segmentation decoder head that takes feature maps as inputs.

Section 6.3.2 of the DINOv3 paper ( https://arxiv.org/abs/2508.10104/) mentions a ViT-adapter without the injection followed by
Mask2Former. In this implementation, Mask2Former is replaced by a simple convolutional head.

Converts a list of [B, C, H, W] feature maps to segmentation logits [B, n_classes, H, W]

###### n_classes: int

Kind: Class Variable

###### in_sizes: list[Size]

Kind: Class Variable

###### parser

Kind: Instance Variable

###### __init__(self, kwargs: Any)

Kind: Method

###### projections

Kind: Instance Variable

###### head

Kind: Instance Variable

###### forward(self, x: list [ Tensor ]) -> Tensor: Tensor

Kind: Method

Semantic segmentation head for feature maps from a
transformer backbone.

@param x: List of successive feature maps of the same dimension
@type x: list[Tensor]
@return: Segmentation logits

@note: Steps:
1. Project each feature map to a channel dim of 256 using 1x1 convolutions.
2. Upsample the feature maps to 1/4 of the image size.
3. Fuse the projected feature maps through summation.
4. Apply segmentation head.
5. Upsample to original input resolution.

##### necks

Kind: Package

###### reppan_neck

Kind: Package

###### blocks

Kind: Module

###### luxonis_train.nodes.necks.reppan_neck.blocks.PANUpBlockBase(abc.ABC, torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, out_channels: int, encode_block: nn.Module)

Kind: Method

Base RepPANNeck up block.

@type in_channels: int
@param in_channels: Number of input channels.
@type out_channels: int
@param out_channels: Number of output channels.
@type encode_block: nn.Module
@param encode_block: Encode block that is used.

###### conv

Kind: Instance Variable

###### upsample

Kind: Instance Variable

###### encode_block

Kind: Instance Variable

###### forward(self, x0: Tensor, x1: Tensor) -> tuple[Tensor, Tensor]: tuple[Tensor, Tensor]

Kind: Method

###### luxonis_train.nodes.necks.reppan_neck.blocks.RepUpBlock(luxonis_train.nodes.necks.reppan_neck.blocks.PANUpBlockBase)

Kind: Class

###### __init__(self, in_channels: int, in_channels_next: int, out_channels: int, n_repeats: int)

Kind: Method

RepPANNeck up block for smaller networks that uses RepBlock.

@type in_channels: int
@param in_channels: Number of input channels.
@type in_channels_next: int
@param in_channels_next: Number of input channels of next input
which is used in concat.
@type out_channels: int
@param out_channels: Number of output channels.
@type n_repeats: int
@param n_repeats: Number of RepVGGBlock repeats.

###### luxonis_train.nodes.necks.reppan_neck.blocks.CSPUpBlock(luxonis_train.nodes.necks.reppan_neck.blocks.PANUpBlockBase)

Kind: Class

###### __init__(self, in_channels: int, in_channels_next: int, out_channels: int, n_repeats: int, e: float)

Kind: Method

RepPANNeck up block for larger networks that uses
CSPStackRepBlock.

@type in_channels: int
@param in_channels: Number of input channels.
@type in_channels_next: int
@param in_channels_next: Number of input channels of next input
which is used in concat.
@type out_channels: int
@param out_channels: Number of output channels.
@type n_repeats: int
@param n_repeats: Number of RepVGGBlock repeats.
@type e: float
@param e: Factor that controls number of intermediate channels.

###### luxonis_train.nodes.necks.reppan_neck.blocks.PANDownBlockBase(abc.ABC, torch.nn.Module)

Kind: Class

###### __init__(self, in_channels: int, downsample_out_channels: int, encode_block: nn.Module)

Kind: Method

Base RepPANNeck up block.

@type in_channels: int
@param in_channels: Number of input channels.
@type downsample_out_channels: int
@param downsample_out_channels: Number of output channels after
downsample.
@type in_channels_next: int
@param in_channels_next: Number of input channels of next input
which is used in concat.
@type out_channels: int
@param out_channels: Number of output channels.
@type n_repeats: int
@param n_repeats: Number of RepVGGBlock repeats.

###### downsample

Kind: Instance Variable

###### encode_block

Kind: Instance Variable

###### forward(self, x0: Tensor, x1: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.necks.reppan_neck.blocks.RepDownBlock(luxonis_train.nodes.necks.reppan_neck.blocks.PANDownBlockBase)

Kind: Class

###### __init__(self, in_channels: int, downsample_out_channels: int, in_channels_next: int, out_channels: int, n_repeats: int)

Kind: Method

RepPANNeck down block for smaller networks that uses
RepBlock.

@type in_channels: int
@param in_channels: Number of input channels.
@type downsample_out_channels: int
@param downsample_out_channels: Number of output channels after
downsample.
@type in_channels_next: int
@param in_channels_next: Number of input channels of next input
which is used in concat.
@type out_channels: int
@param out_channels: Number of output channels.
@type n_repeats: int
@param n_repeats: Number of RepVGGBlock repeats.

###### luxonis_train.nodes.necks.reppan_neck.blocks.CSPDownBlock(luxonis_train.nodes.necks.reppan_neck.blocks.PANDownBlockBase)

Kind: Class

###### __init__(self, in_channels: int, downsample_out_channels: int, in_channels_next: int, out_channels: int, n_repeats: int, e:
float)

Kind: Method

RepPANNeck up block for larger networks that uses
CSPStackRepBlock.

@type in_channels: int
@param in_channels: Number of input channels.
@type downsample_out_channels: int
@param downsample_out_channels: Number of output channels after
downsample.
@type in_channels_next: int
@param in_channels_next: Number of input channels of next input
which is used in concat.
@type out_channels: int
@param out_channels: Number of output channels.
@type n_repeats: int
@param n_repeats: Number of RepVGGBlock repeats.
@type e: float
@param e: Factor that controls number of intermediate channels.

###### reppan_neck

Kind: Module

###### luxonis_train.nodes.necks.reppan_neck.RepPANNeck(luxonis_train.nodes.base_node.BaseNode)

Kind: Class

Implementation of the RepPANNeck module. Supports the version with RepBlock and CSPStackRepBlock (for larger networks)

Adapted from YOLOv6: A Single-Stage Object Detection Framework for Industrial Applications. It has the balance of feature fusion
ability and hardware efficiency.

Variants

The variant determines the depth and width multipliers, block used and intermediate channel scaling factor. Available variants:

"n" or "nano" (default): depth_multiplier=0.33, width_multiplier=0.25, block=RepBlock

"s" or "small": depth_multiplier=0.33, width_multiplier=0.50, block=RepBlock

"m" or "medium": depth_multiplier=0.60, width_multiplier=0.75, block=CSPStackRepBlock, e=2/3

"l" or "large": depth_multiplier=1.0, width_multiplier=1.0, block=CSPStackRepBlock, e=1/2

###### in_channels: list[int]

Kind: Class Variable

###### in_width: list[int]

Kind: Class Variable

###### in_height: list[int]

Kind: Class Variable

###### __init__(self, n_heads: Literal [ 2 , 3 , 4 ] = 3, channels_list: list [ int ] | None = None, n_repeats: list [ int ] |
None = None, depth_multiplier: float = 0.33, width_multiplier: float = 0.25, block: Literal [ ' RepBlock ' , ' CSPStackRepBlock '
] = 'RepBlock', e: float | None = None, weights: str = 'yolo', kwargs)

Kind: Method

@type n_heads: Literal[2,3,4]
@param n_heads: Number of output heads. Defaults to 3. B{Note: Should be same
also on head in most cases.}
@type channels_list: list[int] | None
@param channels_list: List of number of channels for each block.
Defaults to C{[256, 128, 128, 256, 256, 512]}.
@type n_repeats: list[int] | None
@param n_repeats: List of number of repeats of RepVGGBlock.
Defaults to C{[12, 12, 12, 12]}.
@type depth_multiplier: float
@param depth_multiplier: Depth multiplier. Defaults to C{0.33} ("n" variant).
@type width_multiplier: float
@param width_muliplier: Width multiplier. Defaults to C{0.25} ("n" variant).
@type block: Literal["RepBlock", "CSPStackRepBlock"]
@param block: Base block used when building the backbone.
Defaults to C{"RepBlock"} ("n" variant).
@tpe e: float | None
@param e: Factor that controls number of intermediate channels.
Only used when block="CSPStackRepBlock". Defaults to C{None}.

###### n_heads

Kind: Instance Variable

###### up_blocks

Kind: Instance Variable

###### down_blocks

Kind: Instance Variable

###### forward(self, inputs: list [ Tensor ]) -> list[Tensor]: list[Tensor]

Kind: Method

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

Kind: Method

###### get_variants() -> tuple[str, dict[str, Kwargs]]: tuple[str, dict[str, Kwargs]]

Kind: Static Method

###### svtr_neck

Kind: Package

###### blocks

Kind: Module

###### luxonis_train.nodes.necks.svtr_neck.blocks.ConvMixer(torch.nn.Module)

Kind: Class

###### __init__(self, dim: int, height: int, width: int, n_heads: int, kernel_size: tuple [ int , int ] = (3, 3))

Kind: Method

###### height

Kind: Instance Variable

###### width

Kind: Instance Variable

###### dim

Kind: Instance Variable

###### local_mixer

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.necks.svtr_neck.blocks.Attention(torch.nn.Module)

Kind: Class

###### __init__(self, dim: int, height: int | None = None, width: int | None = None, n_heads: int = 8, mixer: Literal [ ' global '
, ' local ' ] = 'global', kernel_size: tuple [ int , int ] | int = (7, 11), qk_scale: float | None = None, attn_drop: float = 0.0,
proj_drop: float = 0.0)

Kind: Method

###### n_heads

Kind: Instance Variable

###### dim

Kind: Instance Variable

###### head_dim

Kind: Instance Variable

###### scale

Kind: Instance Variable

###### qkv

Kind: Instance Variable

###### attn_drop

Kind: Instance Variable

###### proj

Kind: Instance Variable

###### proj_drop

Kind: Instance Variable

###### mask

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### luxonis_train.nodes.necks.svtr_neck.blocks.SVTRBlock(torch.nn.Module)

Kind: Class

###### __init__(self, dim: int, n_heads: int, height: int | None = None, width: int | None = None, mixer: Literal [ ' global ' , '
local ' , ' conv ' ] = 'global', mixer_kernel_size: tuple [ int , int ] = (7, 11), mlp_ratio: float = 4.0, qk_scale: float | None
= None, dropout: float = 0.0, attn_drop: float = 0.0, drop_path: float = 0.0, act_layer: type [ nn.Module ] = nn.GELU, norm_layer:
type [ nn.Module ] = nn.LayerNorm, epsilon: float = 1e-06, prenorm: bool = True)

Kind: Method

###### norm1

Kind: Instance Variable

###### mixer

Kind: Instance Variable

###### drop_path

Kind: Instance Variable

###### norm2

Kind: Instance Variable

###### mlp

Kind: Instance Variable

###### prenorm

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### svtr_neck

Kind: Module

###### luxonis_train.nodes.necks.svtr_neck.SVTRNeck(luxonis_train.nodes.BaseNode)

Kind: Class

SVTR neck.

###### in_channels: int

Kind: Class Variable

###### __init__(self, dims: int = 64, depth: int = 2, mid_channels: int = 120, use_guide: bool = False, n_heads: int = 8,
mlp_ratio: float = 2.0, drop_rate: float = 0.1, attn_drop_rate: float = 0.1, drop_path: float = 0.0, kernel_size: tuple [ int ,
int ] = (3, 3), qk_scale: float | None = None, mixer: Literal [ ' global ' , ' local ' , ' conv ' ] = 'global', height: int | None
= None, width: int | None = None, prenorm: bool = False, kwargs)

Kind: Method

###### depth

Kind: Instance Variable

###### use_guide

Kind: Instance Variable

###### conv1

Kind: Instance Variable

###### conv2

Kind: Instance Variable

###### svtr_block

Kind: Instance Variable

###### norm

Kind: Instance Variable

###### conv3

Kind: Instance Variable

###### conv4

Kind: Instance Variable

###### conv1x1

Kind: Instance Variable

###### out_channels

Kind: Instance Variable

###### forward(self, x: Tensor) -> Tensor: Tensor

Kind: Method

###### initialize_weights(self, method: str | None = None)

Kind: Method

#### optimizers

Kind: Package

##### optimizers

Kind: Module

#### registry

Kind: Module

This module implements a metaclass for automatic registration of classes.

##### CALLBACKS: Registry[type[pl.Callback]]

Kind: Constant

##### LOADERS: Registry[type[lxt.BaseLoaderTorch]]

Kind: Constant

##### LOSSES: Registry[type[lxt.BaseLoss]]

Kind: Constant

##### METRICS: Registry[type[lxt.BaseMetric]]

Kind: Constant

##### MODELS: Registry[type[lxt.BasePredefinedModel]]

Kind: Constant

##### NODES: Registry[type[lxt.BaseNode]]

Kind: Constant

##### OPTIMIZERS: Registry[type[Optimizer]]

Kind: Constant

##### SCHEDULERS: Registry[type[LRScheduler]]

Kind: Constant

##### STRATEGIES: Registry[type[lxt.BaseTrainingStrategy]]

Kind: Constant

##### VISUALIZERS: Registry[type[lxt.BaseVisualizer]]

Kind: Constant

##### T

Kind: Type Variable

##### from_registry(registry: Registry [ type [ T ] ], key: str, args, kwargs) -> T: T

Kind: Function

Get an instance of the class registered under the given key.

@type registry: Registry[type[T]]
@param registry: Registry to get the class from.
@type key: str
@param key: Key to get the class for.
@rtype: T
@return: Instance of the class registered under the given key.

#### schedulers

Kind: Package

##### schedulers

Kind: Module

#### strategies

Kind: Package

##### base_strategy

Kind: Module

##### triple_lr_sgd

Kind: Module

###### luxonis_train.strategies.triple_lr_sgd.TripleLRSGD

Kind: Class

###### model: nn.Module

Kind: Class Variable

###### lr: float

Kind: Class Variable

###### momentum: float

Kind: Class Variable

###### weight_decay: float

Kind: Class Variable

###### nesterov: bool

Kind: Class Variable

###### create_optimizer(self) -> Optimizer: Optimizer

Kind: Method

###### luxonis_train.strategies.triple_lr_sgd.TripleLRSGDStrategy(luxonis_train.strategies.base_strategy.BaseTrainingStrategy)

Kind: Class

###### __init__(self, pl_module: lxt.LuxonisLightningModule, lr: float = 0.02, momentum: float = 0.937, weight_decay: float =
0.0005, nesterov: bool = True, warmup_epochs: int = 3, warmup_bias_lr: float = 0.1, warmup_momentum: float = 0.8, lre: float =
0.0002, cosine_annealing: bool = True)

Kind: Method

TripleLRSGD strategy.

@type pl_module: pl.LightningModule
@param pl_module: The pl_module to be used.
@type params: dict
@param params: The parameters for the strategy. Those are:
- lr: The learning rate.
- momentum: The momentum.
- weight_decay: The weight decay.
- nesterov: Whether to use nesterov.
- warmup_epochs: The number of warmup epochs.
- warmup_bias_lr: The warmup bias learning rate.
- warmup_momentum: The warmup momentum.
- lre: The learning rate for the end of the training.
- cosine_annealing: Whether to use cosine annealing.

###### model

Kind: Instance Variable

###### cfg

Kind: Instance Variable

###### optimizer

Kind: Instance Variable

###### scheduler

Kind: Instance Variable

###### configure_optimizers(self) -> tuple[list[Optimizer], list[LambdaLR]]: tuple[list[Optimizer], list[LambdaLR]]

Kind: Method

###### update_parameters(self)

Kind: Method

##### luxonis_train.strategies.BaseTrainingStrategy(abc.ABC)

Kind: Class

###### __init__(self, pl_module: lxt.LuxonisLightningModule, kwargs)

Kind: Method

###### configure_optimizers(self) -> tuple[list[Optimizer], list[(LRScheduler|dict[str, Any])]]: tuple[list[Optimizer],
list[(LRScheduler|dict[str, Any])]]

Kind: Method

###### update_parameters(self)

Kind: Method

##### luxonis_train.strategies.TripleLRScheduler

Kind: Class

###### optimizer: Optimizer

Kind: Class Variable

###### warmup_epochs: int

Kind: Class Variable

###### warmup_bias_lr: float

Kind: Class Variable

###### warmup_momentum: float

Kind: Class Variable

###### lre: float

Kind: Class Variable

###### cosine_annealing: bool

Kind: Class Variable

###### epochs: int

Kind: Class Variable

###### max_stepnum: int

Kind: Class Variable

###### __post_init__(self)

Kind: Method

###### warmup_stepnum

Kind: Instance Variable

###### step

Kind: Instance Variable

###### lrf

Kind: Instance Variable

###### lf

Kind: Instance Variable

###### create_scheduler(self) -> LambdaLR: LambdaLR

Kind: Method

###### update_learning_rate(self, current_epoch: int)

Kind: Method

#### tasks

Kind: Module

##### luxonis_train.tasks.staticproperty

Kind: Class

###### __init__(self, func: Callable)

Kind: Method

###### func

Kind: Instance Variable

###### __get__(self, _) -> Any: Any

Kind: Method

##### luxonis_train.tasks.Metadata

Kind: Class

###### name: str

Kind: Class Variable

###### typ: UnionType|type

Kind: Class Variable

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

Kind: Method

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

Kind: Method

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

Kind: Method

###### check_type(self, typ: UnionType | type) -> bool: bool

Kind: Method

##### luxonis_train.tasks.Task(abc.ABC)

Kind: Class

###### name: str

Kind: Class Variable

###### required_labels

Kind: Property

###### main_output

Kind: Property

##### luxonis_train.tasks.Classification(luxonis_train.tasks.Task)

Kind: Class

###### __init__(self)

Kind: Method

###### required_labels

Kind: Property

##### luxonis_train.tasks.Segmentation(luxonis_train.tasks.Task)

Kind: Class

###### __init__(self)

Kind: Method

###### required_labels

Kind: Property

##### luxonis_train.tasks.InstanceBaseTask(luxonis_train.tasks.Task)

Kind: Class

###### required_labels

Kind: Property

##### luxonis_train.tasks.BoundingBox(luxonis_train.tasks.InstanceBaseTask)

Kind: Class

###### __init__(self)

Kind: Method

##### luxonis_train.tasks.InstanceSegmentation(luxonis_train.tasks.InstanceBaseTask)

Kind: Class

###### __init__(self)

Kind: Method

###### required_labels

Kind: Property

##### luxonis_train.tasks.InstanceKeypoints(luxonis_train.tasks.InstanceBaseTask)

Kind: Class

###### __init__(self)

Kind: Method

###### required_labels

Kind: Property

##### luxonis_train.tasks.InstanceSegmentationKeypoints(luxonis_train.tasks.InstanceBaseTask)

Kind: Class

###### __init__(self)

Kind: Method

###### required_labels

Kind: Property

##### luxonis_train.tasks.Keypoints(luxonis_train.tasks.Task)

Kind: Class

###### __init__(self)

Kind: Method

###### required_labels

Kind: Property

##### luxonis_train.tasks.Fomo(luxonis_train.tasks.InstanceBaseTask)

Kind: Class

###### __init__(self)

Kind: Method

###### main_output

Kind: Property

##### luxonis_train.tasks.Embeddings(luxonis_train.tasks.Task)

Kind: Class

###### __init__(self)

Kind: Method

###### required_labels

Kind: Property

##### luxonis_train.tasks.AnomalyDetection(luxonis_train.tasks.Task)

Kind: Class

###### __init__(self)

Kind: Method

###### required_labels

Kind: Property

###### main_output

Kind: Property

##### luxonis_train.tasks.Ocr(luxonis_train.tasks.Task)

Kind: Class

###### __init__(self)

Kind: Method

###### required_labels

Kind: Property

##### luxonis_train.tasks.Tasks

Kind: Class

###### CLASSIFICATION

Kind: Property

###### SEGMENTATION

Kind: Property

###### INSTANCE_SEGMENTATION

Kind: Property

###### BOUNDINGBOX

Kind: Property

###### INSTANCE_KEYPOINTS

Kind: Property

###### KEYPOINTS

Kind: Property

###### EMBEDDINGS

Kind: Property

###### ANOMALY_DETECTION

Kind: Property

###### OCR

Kind: Property

###### INSTANCE_SEGMENTATION_KEYPOINTS

Kind: Property

###### FOMO

Kind: Property

#### typing

Kind: Module

##### View: TypeAlias

Kind: Type Alias

##### Labels: TypeAlias

Kind: Type Alias

Labels is a dictionary mapping task names to tensors.

##### AttachIndexType: TypeAlias

Kind: Type Alias

AttachIndexType is used to specify to which output of the prevoius
node does the current node attach to.

It can be either "all" (all outputs), an index of the output or a tuple
of indices of the output (specifying a range of outputs).

##### T

Kind: Type Variable

##### Packet: TypeAlias

Kind: Type Alias

Packet is a dictionary containing either a single instance of a list
of either `torch.Tensor`s or `torch.Size`s.

Packets are used to pass data between nodes of the network graph.

##### get_signature(func: Callable, exclude: Collection [ str ] | None = None) -> dict[str, Parameter]: dict[str, Parameter]

Kind: Function

Get the signature of a function, excluding certain parameters
like 'self' and 'kwargs'.

@type func: Callable
@param func: The function to get the signature of.
@type exclude: Collection[str] | None
@param exclude: A collection of parameter names to exclude from the
signature. Defaults to None, which excludes 'self' and 'kwargs'.
@rtype: dict[str, Parameter]
@return: A dictionary mapping parameter names to their Parameter
objects, excluding the specified parameters.

#### upgrade

Kind: Module

##### luxonis_train.upgrade.NestedDict

Kind: Class

###### __contains__(self, key: str) -> bool: bool

Kind: Method

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

Kind: Method

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

Kind: Method

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

Kind: Method

###### pop(self, key: str, default: Any = ...) -> Any: Any

Kind: Method

###### update(self, key: str, value: Any)

Kind: Method

###### replace(self, old_key: str, new_key: str, value: ParamValue | None | EllipsisType = ...)

Kind: Method

###### log_change(old_field: str, new_field: str)

Kind: Static Method

##### upgrade_config(config: PathType | Params) -> Params: Params

Kind: Function

##### upgrade_installation()

Kind: Function

##### get_latest_version() -> Version|None: Version|None

Kind: Function

#### utils

Kind: Package

##### annotation

Kind: Module

###### ALLOWED_ANNOTATE_LABELS

Kind: Constant

##### boundingbox

Kind: Module

###### IoUType: TypeAlias

Kind: Type Alias

###### BBoxFormatType: TypeAlias

Kind: Type Alias

##### checkpoint

Kind: Module

##### dataset_metadata

Kind: Module

##### exceptions

Kind: Module

##### general

Kind: Module

###### T

Kind: Type Variable

###### clean_url(url: str) -> str: str

Kind: Function

Strip auth from URL, i.e. https://url.com/file.txt?auth -> https://url.com/file.txt.

###### url2file(url: str) -> str: str

Kind: Function

Convert URL to filename, i.e. https://url.com/file.txt?auth -> file.txt.

###### decode_text_metadata_labels(labels: dict [ str , np.ndarray ], metadata_types: dict [ str , type ]) -> dict[str,
np.ndarray]: dict[str, np.ndarray]

Kind: Function

Decode text metadata labels from character-code arrays.

##### keypoints

Kind: Module

##### logging

Kind: Module

##### ocr

Kind: Module

##### segmentation

Kind: Module

##### spatial_transforms

Kind: Module

###### compute_ratio_and_padding(orig_h: int, orig_w: int, train_size: tuple [ int , int ], keep_aspect_ratio: bool) ->
tuple[(float|None), float, float]: tuple[(float|None), float, float]

Kind: Function

Computes the ratio and padding needed to transform bounding
boxes, keypoints, and masks.

##### tracker

Kind: Module

##### default_annotate(head: lxt.nodes.BaseHead, head_output: Packet [ Tensor ], image_paths: list [ Path ], config_preprocessing:
PreprocessingConfig) -> DatasetIterator: DatasetIterator

Kind: Function

Convert head output to a DatasetIterator for annotations in a
format suitable for LuxonisDataset.

@type head: BaseHead
@param head: The head from which to extract annotations.
@type head_output: Packet[Tensor]
@param head_output: The output from the head containing predictions.
@type image_paths: list[Path]
@param image_paths: List of paths to the images corresponding to the
head output.
@type config_preprocessing: PreprocessingConfig
@param config_preprocessing: Preprocessing configuration containing
image size and aspect ratio settings.
@rtype: DatasetIterator
@return: A DatasetIterator yielding annotations for each image.

##### anchors_for_fpn_features(features: list [ Tensor ], strides: Tensor, grid_cell_size: float = 5.0, grid_cell_offset: float =
0.5, multiply_with_stride: bool = False) -> tuple[Tensor, Tensor, list[int], Tensor]: tuple[Tensor, Tensor, list[int], Tensor]

Kind: Function

Generates anchor boxes, points and strides based on FPN feature
shapes and strides.

@type features: list[Tensor]
@param features: List of FPN features.
@type strides: Tensor
@param strides: Strides of FPN features.
@type grid_cell_size: float
@param grid_cell_size: Cell size in respect to input image size.
Defaults to 5.0.
@type grid_cell_offset: float
@param grid_cell_offset: Percent grid cell center's offset. Defaults
to 0.5.
@type multiply_with_stride: bool
@param multiply_with_stride: Whether to multiply per FPN values with
its stride. Defaults to False.
@rtype: tuple[Tensor, Tensor, list[int], Tensor]
@return: BBox anchors, center anchors, number of anchors, strides

##### apply_bounding_box_to_masks(masks: Tensor, bounding_boxes: Tensor) -> Tensor: Tensor

Kind: Function

Crops the given masks to the regions specified by the
corresponding bounding boxes.

@type masks: Tensor
@param masks: Masks tensor of shape [n, h, w].
@type bounding_boxes: Tensor
@param bounding_boxes: Bounding boxes tensor of shape [n, 4].
@rtype: Tensor
@return: Cropped masks tensor of shape [n, h, w].

##### bbox2dist(bbox: Tensor, anchor_points: Tensor, reg_max: float) -> Tensor: Tensor

Kind: Function

Transform bbox(xyxy) to distance(ltrb).

@type bbox: Tensor
@param bbox: Bboxes in "xyxy" format
@type anchor_points: Tensor
@param anchor_points: Head's anchor points
@type reg_max: float
@param reg_max: Maximum regression distances
@rtype: Tensor
@return: BBoxes in distance(ltrb) format

##### bbox_iou(bbox1: Tensor, bbox2: Tensor, bbox_format: BBoxFormatType = 'xyxy', iou_type: IoUType = 'none', element_wise: bool
= False) -> Tensor: Tensor

Kind: Function

Computes IoU between two sets of bounding boxes.

@type bbox1: Tensor
@param bbox1: First set of bboxes [N, 4].
@type bbox2: Tensor
@param bbox2: Second set of bboxes [M, 4].
@type bbox_format: BBoxFormatType
@param bbox_format: Input bounding box format. Defaults to C{"xyxy"}.
@type iou_type: Literal["none", "giou", "diou", "ciou", "siou"]
@param iou_type: IoU type. Defaults to "none".
Possible values are:
- "none": standard IoU
- "giou": Generalized IoU
- "diou": Distance IoU
- "ciou": Complete IoU. Introduced in U{
Enhancing Geometric Factors in Model Learning and
Inference for Object Detection and Instance
Segmentation<https://arxiv.org/pdf/2005.03572.pdf>}.
Implementation adapted from torchvision C{complete_box_iou}
with improved stability.
- "siou": Soft IoU. Introduced in U{
SIoU Loss: More Powerful Learning for Bounding Box
Regression<https://arxiv.org/pdf/2205.12740.pdf>}.
@type element_wise: bool
@param element_wise: If True returns element wise IoUs. Defaults to False.
@rtype: Tensor
@return: IoU between bbox1 and bbox2. If element_wise is True returns [N, M] tensor,
otherwise returns [N] tensor.

##### compute_iou_loss(pred_bboxes: Tensor, target_bboxes: Tensor, target_scores: Tensor | None = None, mask_positive: Tensor |
None = None, iou_type: IoUType = 'giou', bbox_format: BBoxFormatType = 'xyxy', reduction: Literal [ ' sum ' , ' mean ' ] = 'mean')
-> tuple[Tensor, Tensor]: tuple[Tensor, Tensor]

Kind: Function

Computes an IoU loss between 2 sets of bounding boxes.

@type pred_bboxes: Tensor
@param pred_bboxes: Predicted bounding boxes.
@type target_bboxes: Tensor
@param target_bboxes: Target bounding boxes.
@type target_scores: Tensor | None
@param target_scores: Target scores. Defaults to None.
@type mask_positive: Tensor | None
@param mask_positive: Mask for positive samples. Defaults to None.
@type iou_type: L{IoUType}
@param iou_type: IoU type. Defaults to "giou".
@type bbox_format: L{BBoxFormatType}
@param bbox_format: BBox format. Defaults to "xyxy".
@type reduction: Literal["sum", "mean"]
@param reduction: Reduction type. Defaults to "mean".
@rtype: tuple[Tensor, Tensor]
@return: IoU loss and IoU values.

##### dist2bbox(distance: Tensor, anchor_points: Tensor, out_format: BBoxFormatType = 'xyxy', dim: int = -1) -> Tensor: Tensor

Kind: Function

Transform distance (ltrb) to box ("xyxy", "xywh" or "cxcywh").

@type distance: Tensor
@param distance: Distance predictions
@type anchor_points: Tensor
@param anchor_points: Head's anchor points
@type out_format: BBoxFormatType
@param out_format: BBox output format. Defaults to "xyxy".
@rtype: Tensor
@param dim: Dimension to split distance tensor. Defaults to -1.
@rtype: Tensor
@return: BBoxes in correct format

##### keypoints_to_bboxes(keypoints: list [ Tensor ], img_height: int, img_width: int, box_width: int = 5, visibility_threshold:
float = 0.5) -> list[Tensor]: list[Tensor]

Kind: Function

Convert keypoints to bounding boxes in xyxy format with cls_id
and score, filtering low-visibility keypoints.

@type keypoints: list[Tensor]
@param keypoints: List of tensors of keypoints with shape [N, 1, 4]
(x, y, v, cls_id).
@type img_height: int
@param img_height: Height of the image.
@type img_width: int
@param img_width: Width of the image.
@type box_width: int
@param box_width: Width of the bounding box in pixels. Defaults to
2.
@type visibility_threshold: float
@param visibility_threshold: Minimum visibility score to include a
keypoint. Defaults to 0.5.
@rtype: list[Tensor]
@return: List of tensors of bounding boxes with shape [N, 6] (x_min,
y_min, x_max, y_max, score, cls_id).

##### non_max_suppression(preds: Tensor, n_classes: int, conf_thres: float = 0.25, iou_thres: float = 0.45, keep_classes: list [
int ] | None = None, agnostic: bool = False, multi_label: bool = False, bbox_format: BBoxFormatType = 'xyxy', max_det: int = 300,
predicts_objectness: bool = True) -> list[Tensor]: list[Tensor]

Kind: Function

Non-maximum suppression on model's predictions to keep only best
instances.

@type preds: Tensor
@param preds: Model's prediction tensor of shape [bs, N, M].
@type n_classes: int
@param n_classes: Number of model's classes.
@type conf_thres: float
@param conf_thres: Boxes with confidence higher than this will be kept. Defaults to
0.25.
@type iou_thres: float
@param iou_thres: Boxes with IoU higher than this will be discarded. Defaults to
0.45.
@type keep_classes: list[int] | None
@param keep_classes: Subset of classes to keep, if None then keep all of them.
Defaults to None.
@type agnostic: bool
@param agnostic: Whether perform NMS per class or treat all classes the same.
Defaults to False.
@type multi_label: bool
@param multi_label: Whether one prediction can have multiple labels. Defaults to
False.
@type bbox_format: BBoxFormatType
@param bbox_format: Input bbox format. Defaults to "xyxy".
@type max_det: int
@param max_det: Number of maximum output detections. Defaults to 300.
@type predicts_objectness: bool
@param predicts_objectness: Whether head predicts objectness confidence. Defaults to
True.
@rtype: list[Tensor]
@return: list of kept detections for each image, boxes in "xyxy" format. Tensors
with shape [n_kept, M]

##### CHECKPOINT_FILTERED_STATE_DICT_PATTERN

Kind: Constant

##### filter_checkpoint_state_dict(state_dict: Mapping [ str , Tensor ]) -> dict[str, Tensor]: dict[str, Tensor]

Kind: Function

##### luxonis_train.utils.DatasetMetadata

Kind: Class

Metadata about the dataset.

###### __init__(self, classes: dict [ str , dict [ str , int ] ] | None = None, n_keypoints: dict [ str , int ] | None = None,
metadata_types: dict [ str , ( type [ int ] | type [ Category ] | type [ float ] | type [ str ] ) ] | None = None, loader:
BaseLoaderTorch | None = None)

Kind: Method

An object containing metadata about the dataset. Used to
infer the number of classes, number of keypoints, I{etc.}
instead of passing them as arguments to the model.

@type classes: dict[str, dict[str, int]] | None
@param classes: Dictionary mapping tasks to the classes.
@type n_keypoints: dict[str, int] | None
@param n_keypoints: Dictionary mapping tasks to the number of
keypoints.
@type loader: DataLoader | None
@param loader: Dataset loader.

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

Kind: Method

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

Kind: Method

###### __rich_repr__(self) -> Iterator[tuple[str, Any]]: Iterator[tuple[str, Any]]

Kind: Method

###### dump(self) -> dict[str, Any]: dict[str, Any]

Kind: Method

Dumps the metadata to a dictionary.

@rtype: dict[str, dict[str, int] | int | dict[str, type]]
@return: Dictionary containing the metadata.

###### task_names

Kind: Property

Gets the names of the tasks present in the dataset.

###### n_classes(self, task_name: str | None = None) -> int: int

Kind: Method

Gets the number of classes for the specified task.

@type task_name: str | None
@param task_name: Task to get the number of classes for.
@rtype: int
@return: Number of classes for the specified task type.
@raises ValueError: If the C{task} is not present in the
dataset.
@raises RuntimeError: If the C{task} was not provided and the
dataset contains different number of classes for different
task types.

###### n_keypoints(self, task_name: str | None = None) -> int: int

Kind: Method

Gets the number of keypoints for the specified task.

@type task_name: str | None
@param task_name: Task to get the number of keypoints for.
@rtype: int
@return: Number of keypoints for the specified task type.
@raises ValueError: If the C{task} is not present in the
dataset.
@raises RuntimeError: If the C{task} was not provided and the
dataset contains different number of keypoints for different
task types.

###### classes(self, task_name: str | None = None) -> bidict[str, int]: bidict[str, int]

Kind: Method

Gets the class names for the specified task.

@type task_name: str | None
@param task_name: Task to get the class names for.
@rtype: bidict[str, int]
@return: Bidirectional dictionary mapping class names to their
indices for the specified task type.
@raises ValueError: If the C{task} is not present in the
dataset.
@raises RuntimeError: If the C{task} was not provided and the
dataset contains different class names for different label
types.

###### metadata_types

Kind: Property

Gets the types of metadata for the dataset.

###### from_loader

Kind: Class Method

Creates a L{DatasetMetadata} object from a L{LuxonisDataset}.

@type loader: LuxonisDataset
@param loader: Loader to read the metadata from.
@rtype: DatasetMetadata
@return: Instance of L{DatasetMetadata} created from the
provided dataset.

##### IncompatibleError

Kind: Exception

Raised when two parts of the model are incompatible with each other.

##### luxonis_train.utils.Counter

Kind: Class

Simple counter that can be used to generate unique IDs or indices.

###### __init__(self, start: int = 0)

Kind: Method

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

Kind: Method

##### get_attribute_check_none(obj: object, attribute: str) -> Any: Any

Kind: Function

Get private attribute from object and check if it is not None.

Example:

>>> class Person:
... def __init__(self, age: int | None = None):
... self._age = age
...
... @property
... def age(self):
... return get_attribute_check_none(self, "age")

>>> mike = Person(20)
>>> print(mike.age)
20

>>> amanda = Person()
>>> print(amanda.age)
Traceback (most recent call last):
ValueError: attribute 'age' was not set

@type obj: object
@param obj: Object to get attribute from.

@type attribute: str
@param attribute: Name of the attribute to get.

@rtype: Any
@return: Value of the attribute.

@raise ValueError: If the attribute is None.

##### get_batch_instances(batch_index: int, bboxes: Tensor, payload: Tensor | None = None) -> Tensor: Tensor

Kind: Function

Get instances from batched data, where the batch index is
encoded.

as the first column of the bounding boxes.
@type batch_index: int
@param batch_index: Batch index.
@type bboxes: Tensor
@param bboxes: Tensor of bounding boxes. Must have the batch index
as the first column.
@type payload: Tensor | None
@param payload: Additional tensor to be batched with the bounding
boxes. This tensor is in the same batch order, but doesn't
contain the batch index itself. If unset, returns the bounding
box instances (without the batch index).
@rtype: Tensor
@return: Instances from the batched data.

##### get_with_default(value: T | None, action_name: str, caller_name: str | None = None, default: T) -> T: T

Kind: Function

Returns value if it is not C{None}, otherwise returns the default
value and log an info.

@type value: T | None
@param value: Value to return.
@type action_name: str
@param action_name: Name of the action for which the default value
is being used. Used for logging.
@type caller_name: str | None
@param caller_name: Name of the caller function. Used for logging.
@type default: T
@param default: Default value to return if C{value} is C{None}.
@rtype: T
@return: C{value} if it is not C{None}, otherwise C{default}.

##### infer_upscale_factor(in_size: tuple [ int , int ] | int, orig_size: tuple [ int , int ] | int) -> int: int

Kind: Function

Infer the upscale factor from the input shape and the original
shape.

@type in_size: tuple[int, int] | int
@param in_size: Input shape as a tuple of (height, width) or just
one of them.
@type orig_size: tuple[int, int] | int
@param orig_size: Original shape as a tuple of (height, width) or
just one of them.
@rtype: int
@return: Upscale factor.
@raise ValueError: If the C{in_size} cannot be upscaled to the
C{orig_size}. This can happen if the upscale factors are not
integers or are different.

##### instances_from_batch(bboxes: Tensor, args: Tensor, batch_size: int | None = None) -> Iterator[tuple[Tensor,
...]]|Iterator[Tensor]: Iterator[tuple[Tensor, ...]]|Iterator[Tensor]

Kind: Function

Generate instances from batched data, where the batch index is
encoded as the first column of the bounding boxes.

Example::
>>> bboxes = torch.tensor([[0, 1], [0, 2], [1, 3]])
>>> keypoints = torch.tensor([[0.1], [0.2], [0.3]])
>>> for bbox, kpt in instances_from_batch(bboxes, keypoints):
... print(bbox, kpt)
tensor([[1], [2]]) tensor([[0.1], [0.2]])
tensor([[3]]) tensor([[0.3]])

@type bboxes: Tensor
@param bboxes: Tensor of bounding boxes. Must have the batch index
as the first column.
@type *args: Tensor
@param *args: Additional tensors to be batched with the bounding
boxes. These tensors are in the same batch order, but don't
contain the batch index themselves.
@type batch_size: int
@param batch_size: The batch size. Important in case of empty
tensors. If provided and the tensors are empty, the generator
will yield C{batch_size} empty tensors. If not provided, the
generator will yield nothing. Defaults to C{None}.
@rtype: Iterator[tuple[Tensor, ...]]
@return: Generator of instances, where the first element is the
bounding box tensor (with the batch index stripped) and the
rest are the additional tensors (keypoints, masks, etc.).

##### make_divisible(x: float, divisor: int) -> int: int

Kind: Function

Upward revision the value x to make it evenly divisible by the
divisor.

Equivalent to M{ceil(x / divisor) * divisor}.

@type x: int | float
@param x: Value to be revised.
@type divisor: int
@param divisor: Divisor.
@rtype: int
@return: Revised value.

##### safe_download(url: PathType | None, file: str | None = None, dir: PathType = '.cache/luxonis_train', retry: int = 3, force:
bool = False) -> Path|None: Path|None

Kind: Function

Downloads file from the web and returns either local path or None
if downloading failed.

@type url: str | None
@param url: URL of the file you want to download. If None, returns
None.
@type file: str | None
@param file: Name of the saved file, if None infers it from URL.
Defaults to None.
@type dir: str
@param dir: Directory to store downloaded file in. Defaults to
'.cache_data'.
@type retry: int
@param retry: Number of retries when downloading. Defaults to 3.
@type force: bool
@param force: Whether to force redownload if file already exists.
Defaults to False.
@rtype: Path | None
@return: Path to local file or None if downloading failed.

##### to_shape_packet(packet: Packet [ Tensor ]) -> Packet[Size]: Packet[Size]

Kind: Function

Converts a packet of tensors to a packet of shapes. Used for
debugging purposes.

@type packet: Packet[Tensor]
@param packet: Packet of tensors.
@rtype: Packet[Size]
@return: Packet of shapes.

##### compute_pose_oks(predictions: Tensor, targets: Tensor, sigmas: Tensor, gt_bboxes: Tensor | None = None, pose_area: Tensor |
None = None, eps: float = 1e-09, area_factor: float = 0.53, use_cocoeval_oks: bool = True) -> Tensor: Tensor

Kind: Function

Compute batched Object Keypoint Similarity (OKS) between ground
truth and predicted keypoints.

@type pred_kpts: Tensor
@param pred_kpts: Predicted keypoints with shape [N, M2,
n_keypoints, 3]
@type gt_kpts: Tensor
@param gt_kpts: Ground truth keypoints with shape [N, M1,
n_keypoints, 3]
@type sigmas: Tensor
@param sigmas: Sigmas for each keypoint, shape [n_keypoints]
@type gt_bboxes: Tensor
@param gt_bboxes: Ground truth bounding boxes in XYXY format with
shape [N, M1, 4]
@type pose_area: Tensor
@param pose_area: Area of the pose, shape [N, M1, 1, 1]
@type eps: float
@param eps: A small constant to ensure numerical stability
@type area_factor: float
@param area_factor: Factor to scale the area of the pose
@type use_cocoeval_oks: bool
@param use_cocoeval_oks: Whether to use the same OKS formula as in
COCOEval or use the one from the definition. Defaults to True.
@rtype: Tensor
@return: A tensor of OKS values with shape [N, M1, M2]

##### get_center_keypoints(bboxes: Tensor, height: int = 1, width: int = 1) -> Tensor: Tensor

Kind: Function

Get center keypoints from bounding boxes.

@type bboxes: Tensor
@param bboxes: Tensor of bounding boxes.
@type height: int
@param height: Image height. Defaults to C{1} (normalized).
@type width: int
@param width: Image width. Defaults to C{1} (normalized).
@rtype: Tensor
@return: Tensor of center keypoints.

##### get_sigmas(sigmas: list [ float ] | None, n_keypoints: int, caller_name: str | None = None) -> Tensor: Tensor

Kind: Function

Validate or create sigma values for each keypoint.

@type sigmas: list[float] | None
@param sigmas: List of sigmas for each keypoint. If C{None}, then
default sigmas are used.
@type n_keypoints: int
@param n_keypoints: Number of keypoints.
@type caller_name: str | None
@param caller_name: Name of the caller function. Used for logging.
@rtype: Tensor
@return: Tensor of sigmas.

##### insert_class(keypoints: Tensor, bboxes: Tensor) -> Tensor: Tensor

Kind: Function

Insert class index into keypoints tensor.

@type keypoints: Tensor
@param keypoints: Tensor of keypoints.
@type bboxes: Tensor
@param bboxes: Tensor of bounding boxes with class index.
@rtype: Tensor
@return: Tensor of keypoints with class index.

##### setup_logging(file: PathType | None = None, use_rich: bool = True)

Kind: Function

##### luxonis_train.utils.OCRDecoder

Kind: Class

OCR decoder for converting model predictions to text.

###### __init__(self, char_to_int: dict, ignored_tokens: list [ int ] | None = None, is_remove_duplicate: bool = True)

Kind: Method

Initializes the OCR decoder.

@type char_to_int: dict
@param char_to_int: A dictionary mapping characters to integers.
@type ignored_tokens: list[int]
@param ignored_tokens: A list of tokens to ignore when decoding.
Defaults to [0].
@type is_remove_duplicate: bool
@param is_remove_duplicate: Whether to remove duplicate
characters. Defaults to True.

###### ignored_tokens

Kind: Instance Variable

###### int_to_char

Kind: Instance Variable

###### is_remove_duplicate

Kind: Instance Variable

###### decode(self, preds: Tensor) -> list[tuple[str, float]]: list[tuple[str, float]]

Kind: Method

Decodes the model predictions to text.

@type preds: Tensor
@param preds: A tensor containing the model predictions.
@rtype: list[tuple[str, float]]
@return: A list of tuples containing the decoded text and
confidence score.

###### __call__(self, preds: Tensor) -> list[tuple[str, float]]: list[tuple[str, float]]

Kind: Method

##### luxonis_train.utils.OCREncoder

Kind: Class

OCR encoder for converting text to model targets.

###### __init__(self, alphabet: list [ str ], ignore_unknown: bool = True)

Kind: Method

Initializes the OCR encoder.

@type alphabet: list[str]
@param alphabet: A list of characters in the alphabet.
@type ignore_unknown: bool
@param ignore_unknown: Whether to ignore unknown characters.
Defaults to True.

###### char_to_int

Kind: Instance Variable

###### ignore_unknown

Kind: Instance Variable

###### encode(self, targets: Tensor) -> Tensor: Tensor

Kind: Method

Encodes the text targets to model targets.

@type targets: list[int]
@param targets: A list of text targets.
@rtype: Tensor
@return: A tensor containing the encoded targets.

###### __call__(self, targets: Tensor) -> Tensor: Tensor

Kind: Method

###### alphabet

Kind: Property

###### n_classes

Kind: Property

##### seg_output_to_bool(data: Tensor, binary_threshold: float = 0.5) -> Tensor: Tensor

Kind: Function

Converts seg head output to 2D boolean mask for visualization.

##### transform_boxes(raw_boxes: np.ndarray, orig_h: int, orig_w: int, train_size: tuple [ int , int ], keep_aspect_ratio: bool)
-> np.ndarray: np.ndarray

Kind: Function

Transforms raw bounding boxes to normalized coordinates based on
the original image size and training size.

##### transform_keypoints(raw_kpts: np.ndarray, orig_h: int, orig_w: int, train_size: tuple [ int , int ], keep_aspect_ratio:
bool) -> np.ndarray: np.ndarray

Kind: Function

Transforms raw keypoints to normalized coordinates based on the
original image size and training size.

##### transform_masks(raw_masks: np.ndarray, orig_h: int, orig_w: int, train_size: tuple [ int , int ], keep_aspect_ratio: bool)
-> np.ndarray: np.ndarray

Kind: Function

Transforms raw masks to normalized size based on the original
image size and training size.

##### luxonis_train.utils.LuxonisTrackerPL(luxonis_ml.tracker.LuxonisTracker, lightning.pytorch.loggers.logger.Logger)

Kind: Class

Implementation of LuxonisTracker that is compatible with PytorchLightning.

###### __init__(self, _auto_finalize: bool = True, kwargs)

Kind: Method

@type _auto_finalize: bool
@param _auto_finalize: If True, the run will be finalized automatically when the training ends.
If set to C{False}, the user will have to call the L{_finalize} method manually.

@type kwargs: dict
@param kwargs: Additional keyword arguments to be passed to the L{LuxonisTracker}.

###### finalize

Kind: Instance Variable

#### variants

Kind: Module

##### luxonis_train.variants.VariantMeta(luxonis_ml.utils.registry.AutoRegisterMeta)

Kind: Class

A metaclass for classes that support variants.

When a class with this metaclass is instantiated with the 'variant' keyword argument, the metaclass will look up the corresponding
parameters for that variant using the class's get_variants method. It will then call the class's __init__ method with those
parameters, along with any other provided arguments, taking care of managing conflicts between explicitly provided arguments and
variant parameters.

If the variant argument is not provided or is set to 'none', the class will be instantiated normally.

Additionally, if the class has a __post_init__ method, it will be called after the initialization. This method can be used for any
additional setup that needs to occur after the object is created.

###### __call__(cls: type [ VariantBase ], args, variant: str | None = None, kwargs)

Kind: Method

##### luxonis_train.variants.VariantBase(abc.ABC)

Kind: Class

###### get_variants() -> tuple[str, dict[str, Kwargs]]: tuple[str, dict[str, Kwargs]]

Kind: Static Method

Returns a name of the default varaint and a dictionary of
available variants.

The keys are the variant names, and the values are dictionaries
of parameters which can be used as C{**kwargs} for the
constructor of a derived class.

@rtype: tuple[str, dict[str, Kwargs]]
@return: A tuple containing the default variant name and a
dictionary of available variants with their parameters.

##### add_variant_aliases(variants: dict [ str , Kwargs ], aliases: dict [ str , Collection [ str ] ] | Literal [ ' yolo ' ] =
'yolo') -> dict[str, Kwargs]: dict[str, Kwargs]

Kind: Function

Adds yolo-style aliases to the variants dictionary.

#### __version__: str

Kind: Constant

#### __semver__: SemanticVersion

Kind: Constant
