class documentation

Batch-based augmentation that blends two images together.

Blending is performed by a convex combination of the two images based on a mixing coefficient α sampled from a specified distribution. The resulting image is computed as:

 = αxi + (1 − α)xj

If the images have different sizes, the second image is resized to match the first one.

Method __init__ Create a MixUp augmentation.
Method apply Apply MixUp to a batch of images.
Method apply_to_bboxes Apply MixUp to a batch of bounding boxes.
Method apply_to_instance_mask Apply MixUp to a batch of instance segmentation masks.
Method apply_to_keypoints Apply MixUp to a batch of keypoints.
Method apply_to_mask Apply MixUp to a batch of semantic segmentation masks.
Method get_params Sample a mixing coefficient from the specified distribution.
Method _resize Undocumented
Instance Variable _alpha Undocumented
Instance Variable _resize_transform Undocumented

Inherited from BatchTransform:

Method apply_to_array Apply the transformation to a batch of generic arrays.
Method apply_to_classification Apply the transformation to a batch of classification labels.
Method apply_to_metadata Apply the transformation to a batch of metadata arrays.
Method update_transform_params Update the parameters dictionary with the shape of the input images.
Instance Variable batch_size Number of samples consumed by one application of the transform.
Property targets Undocumented
def __init__(self, alpha: float | tuple[float, float] = 0.5, keep_aspect_ratio: bool = True, p: float = 0.5):

Create a MixUp augmentation.

Parameters
alpha:float | tuple[float, float]Mixing coefficient or range to uniformly sample from. Must stay in [0, 1].
keep_aspect_ratio:boolWhether to preserve the second image's aspect ratio when resizing.
p:floatProbability of applying the transform.
Raises
ValueErrorIf alpha falls outside [0, 1] or an alpha range is not in ascending order.
@override
def apply(self, image_batch: list[np.ndarray], image_shapes: list[tuple[int, int]], alpha: float, **_) -> np.ndarray:

Apply MixUp to a batch of images.

Parameters
image_batch:list[np.ndarray]Images to transform. Each image should be of shape (H, W, C) or (H, W).
image_shapes:list[tuple[int, int]]Shapes of the original images.
alpha:floatMixing coefficient.
**_Undocumented
Returns
np.ndarrayA single image of shape (Hout, Wout, C) or (Hout, Wout) resulting from blending the input images.
@override
def apply_to_bboxes(self, bboxes_batch: list[np.ndarray], image_shapes: list[tuple[int, int]], **_) -> np.ndarray:

Apply MixUp to a batch of bounding boxes.

Parameters
bboxes_batch:list[np.ndarray]Bounding boxes to transform.
image_shapes:list[tuple[int, int]]Original image shapes.
**_Undocumented
Returns
np.ndarrayTransformed bounding boxes.
@override
def apply_to_instance_mask(self, masks_batch: list[np.ndarray], image_shapes: list[tuple[int, int]], **_) -> np.ndarray:

Apply MixUp to a batch of instance segmentation masks.

Parameters
masks_batch:list[np.ndarray]Masks to transform. Each mask should be of shape (H, W, N), where N is the number of instances.
image_shapes:list[tuple[int, int]]Shapes of the original images.
**_Undocumented
Returns
np.ndarrayA single instance masks of shape (Hout, Wout, N).
@override
def apply_to_keypoints(self, keypoints_batch: list[np.ndarray], image_shapes: list[tuple[int, int]], **_) -> np.ndarray:

Apply MixUp to a batch of keypoints.

Parameters
keypoints_batch:list[np.ndarray]Keypoints to transform.
image_shapes:list[tuple[int, int]]Original image shapes.
**_Undocumented
Returns
np.ndarrayTransformed keypoints.
@override
def apply_to_mask(self, masks_batch: list[np.ndarray], image_shapes: list[tuple[int, int]], alpha: float, **_) -> np.ndarray:

Apply MixUp to a batch of semantic segmentation masks.

Blends masks together. In case of a conflict, the class from the mask associated with the higher α is chosen.

Parameters
masks_batch:list[np.ndarray]Masks to transform. Each mask should be of shape (H, W, C) or (H, W).
image_shapes:list[tuple[int, int]]Shapes of the original images.
alpha:floatMixing coefficient.
**_Undocumented
Returns
np.ndarrayA single segmentation mask of shape (Hout, Wout, C) or (Hout, Wout).
@override
def get_params(self) -> dict[str, Any]:

Sample a mixing coefficient from the specified distribution.

Returns
dict[str, Any]Dictionary containing "alpha" key with the sampled mixing coefficient.
def _resize(self, data: np.ndarray, shapes: list[tuple[int, int]], target_type: Literal['image', 'mask', 'bboxes', 'keypoints'], alpha: float | None = None, **kwargs) -> np.ndarray:

Undocumented

_alpha =

Undocumented

_resize_transform =

Undocumented