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:
x̃ = α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 |
Apply MixUp to a batch of bounding boxes. |
| Method | apply |
Apply MixUp to a batch of instance segmentation masks. |
| Method | apply |
Apply MixUp to a batch of keypoints. |
| Method | apply |
Apply MixUp to a batch of semantic segmentation masks. |
| Method | get |
Sample a mixing coefficient from the specified distribution. |
| Method | _resize |
Undocumented |
| Instance Variable | _alpha |
Undocumented |
| Instance Variable | _resize |
Undocumented |
Inherited from BatchTransform:
| Method | apply |
Apply the transformation to a batch of generic arrays. |
| Method | apply |
Apply the transformation to a batch of classification labels. |
| Method | apply |
Apply the transformation to a batch of metadata arrays. |
| Method | update |
Update the parameters dictionary with the shape of the input images. |
| Instance Variable | batch |
Number of samples consumed by one application of the transform. |
| Property | targets |
Undocumented |
float | tuple[ float, float] = 0.5, keep_aspect_ratio: bool = True, p: float = 0.5):
¶
Create a MixUp augmentation.
| Parameters | |
alpha:float | tuple[ | Mixing coefficient or range to uniformly sample from. Must stay in [0, 1]. |
keepbool | Whether to preserve the second image's aspect ratio when resizing. |
p:float | Probability of applying the transform. |
| Raises | |
ValueError | If alpha falls outside [0, 1] or an alpha range is not in ascending order. |
list[ np.ndarray], image_shapes: list[ tuple[ int, int]], alpha: float, **_) -> np.ndarray:
¶
Apply MixUp to a batch of images.
| Parameters | |
imagelist[ | Images to transform. Each image should be of shape (H, W, C) or (H, W). |
imagelist[ | Shapes of the original images. |
alpha:float | Mixing coefficient. |
| **_ | Undocumented |
| Returns | |
np.ndarray | A single image of shape (Hout, Wout, C) or (Hout, Wout) resulting from blending the input images. |
list[ np.ndarray], image_shapes: list[ tuple[ int, int]], **_) -> np.ndarray:
¶
Apply MixUp to a batch of bounding boxes.
| Parameters | |
bboxeslist[ | Bounding boxes to transform. |
imagelist[ | Original image shapes. |
| **_ | Undocumented |
| Returns | |
np.ndarray | Transformed bounding boxes. |
list[ np.ndarray], image_shapes: list[ tuple[ int, int]], **_) -> np.ndarray:
¶
Apply MixUp to a batch of instance segmentation masks.
| Parameters | |
maskslist[ | Masks to transform. Each mask should be of shape (H, W, N), where N is the number of instances. |
imagelist[ | Shapes of the original images. |
| **_ | Undocumented |
| Returns | |
np.ndarray | A single instance masks of shape (Hout, Wout, N). |
list[ np.ndarray], image_shapes: list[ tuple[ int, int]], **_) -> np.ndarray:
¶
Apply MixUp to a batch of keypoints.
| Parameters | |
keypointslist[ | Keypoints to transform. |
imagelist[ | Original image shapes. |
| **_ | Undocumented |
| Returns | |
np.ndarray | Transformed keypoints. |
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 | |
maskslist[ | Masks to transform. Each mask should be of shape (H, W, C) or (H, W). |
imagelist[ | Shapes of the original images. |
alpha:float | Mixing coefficient. |
| **_ | Undocumented |
| Returns | |
np.ndarray | A single segmentation mask of shape (Hout, Wout, C) or (Hout, Wout). |
Sample a mixing coefficient from the specified distribution.
| Returns | |
dict[ | Dictionary containing "alpha" key with the sampled mixing coefficient. |
np.ndarray, shapes: list[ tuple[ int, int]], target_type: Literal[ 'image', 'mask', 'bboxes', 'keypoints'], alpha: float | None = None, **kwargs) -> np.ndarray:
¶
Undocumented