mixup
最后更新
luxonis_ml.data.augmentations.custom.mixup类
MixUp
x̃ = α**xi + (1 − α)xj如果图像大小不同,则第二张图像将调整大小以匹配第一张图像。
方法
init
Python
1def __init__(alpha: float | tuple[float, float] = 0.5, keep_aspect_ratio: bool = True, p: float = 0.5):alpha(float | tuple[float, float]): 混合系数或要从中均匀采样的范围。必须保持在 [0, 1] 之间。keep_aspect_ratio(bool): 调整大小时是否保留第二张图像的纵横比。p(float): 应用变换的概率。
ValueError: 如果alpha超出 [0, 1] 范围或alpha范围不是升序。
apply
Python
1def apply(image_batch: list[np.ndarray], image_shapes: list[tuple[int, int]], alpha: float, **_) -> np.ndarray:image_batch(list[np.ndarray]): 要变换的图像。每张图像的形状应为 (H, W, C) 或 (H, W)。image_shapes(list[tuple[int, int]]): 原始图像的形状。alpha(float): 混合系数。**_
np.ndarray: 形状为 (Hout, Wout, C) 或 (Hout, Wout) 的单张图像,由输入图像混合而成。
apply_to_bboxes
Python
1def apply_to_bboxes(bboxes_batch: list[np.ndarray], image_shapes: list[tuple[int, int]], **_) -> np.ndarray:bboxes_batch(list[np.ndarray]): 要变换的边界框。image_shapes(list[tuple[int, int]]): 原始图像形状。**_
np.ndarray: 变换后的边界框。
apply_to_instance_mask
Python
1def apply_to_instance_mask(masks_batch: list[np.ndarray], image_shapes: list[tuple[int, int]], **_) -> np.ndarray:masks_batch(list[np.ndarray]): 要变换的掩码。每个掩码的形状应为 (H, W, N),其中 N 是实例数。image_shapes(list[tuple[int, int]]): 原始图像的形状。**_
np.ndarray: 形状为 (Hout, Wout, N) 的单个实例掩码。
apply_to_keypoints
Python
1def apply_to_keypoints(keypoints_batch: list[np.ndarray], image_shapes: list[tuple[int, int]], **_) -> np.ndarray:keypoints_batch(list[np.ndarray]): 要变换的关键点。image_shapes(list[tuple[int, int]]): 原始图像形状。**_
np.ndarray: 变换后的关键点。
apply_to_mask
Python
1def apply_to_mask(masks_batch: list[np.ndarray], image_shapes: list[tuple[int, int]], alpha: float, **_) -> np.ndarray:masks_batch(list[np.ndarray]): 要变换的掩码。每个掩码的形状应为 (H, W, C) 或 (H, W)。image_shapes(list[tuple[int, int]]): 原始图像的形状。alpha(float): 混合系数。**_
np.ndarray: 形状为 (Hout, Wout, C) 或 (Hout, Wout) 的单个分割掩码。
get_params
Python
1def get_params(self) -> dict[str, Any]:dict[str, Any]: 包含带有采样混合系数的"alpha"键的字典。