class Mosaic4(BatchTransform):
Constructor: Mosaic4(height, width, image_fill_value, mask_fill_value, ...)
Batch-based augmentation that creates a mosaic of four images.
The transform arranges four images in a deterministic 2×2 grid:
| 1 | 2 |
| 3 | 4 |
Images may have different sizes, but they must have the same number of channels. The result is cropped around the mosaic center to out_width by out_height and padded when needed with the specified fill values.
An example of the Mosaic4 augmentation.
| Method | __init__ |
Create a Mosaic4 augmentation. |
| Method | apply |
Apply mosaic augmentation to a batch of images. |
| Method | apply |
Apply mosaic augmentation to a batch of bounding boxes. |
| Method | apply |
Apply mosaic augmentation to a batch of instance segmentation masks. |
| Method | apply |
Apply mosaic augmentation to a batch of keypoints. |
| Method | apply |
Apply mosaic augmentation to a batch of semantic segmentation masks. |
| Method | generate |
Generate a random crop center within the bounds of the mosaic image size. |
| Method | get |
Get parameters dependent on the targets. |
| Static Method | _apply |
Adjust bounding box coordinates for the mosaic grid position. |
| Static Method | _apply |
Arrange the images in a 2×2 grid layout. |
| Static Method | _apply |
Undocumented |
| Static Method | _apply |
Adjust keypoint coordinates for the mosaic grid position. |
| Static Method | _compute |
Undocumented |
| Static Method | _compute |
Undocumented |
| Instance Variable | _height |
Undocumented |
| Instance Variable | _image |
Undocumented |
| Instance Variable | _mask |
Undocumented |
| Instance Variable | _width |
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 |
int | None = None, width: int | None = None, image_fill_value: float | list[ int] | list[ float] | None = None, mask_fill_value: float | list[ int] | list[ float] | None = None, p: float = 0.5, out_height: int | None = None, out_width: int | None = None, value: float | list[ int] | list[ float] | None = None, mask_value: float | list[ int] | list[ float] | None = None):
¶
Create a Mosaic4 augmentation.
| Parameters | |
height:int | None | Output image height. |
width:int | None | Output image width. |
imagefloat | list[ | Padding value for images. |
maskfloat | list[ | Padding value for masks. |
p:float | Probability of applying the transform. |
outint | None |
Deprecated since version 0.9.0: Use height instead.
|
outint | None |
Deprecated since version 0.9.0: Use width instead.
|
value:float | list[ |
Deprecated since version 0.9.0: Use image_fill_value instead.
|
maskfloat | list[ |
Deprecated since version 0.9.0: Use mask_fill_value instead.
|
| Raises | |
ValueError | If the resolved output height or width is missing or not greater than 0. |
list[ np.ndarray], x_crop: int, y_crop: int, **_) -> np.ndarray:
¶
Apply mosaic augmentation to a batch of images.
| Parameters | |
imagelist[ | Images to transform. Each image should be of shape (H, W, C) or (H, W). |
xint | X-coordinate of the crop start point. |
yint | Y-coordinate of the crop start point. |
| **_ | Undocumented |
| Returns | |
np.ndarray | A single image of shape (Hout, Wout, C) or (Hout, Wout). |
list[ np.ndarray], image_shapes: list[ tuple[ int, int]], x_crop: int, y_crop: int, **_) -> np.ndarray:
¶
Apply mosaic augmentation to a batch of bounding boxes.
| Parameters | |
bboxeslist[ | Bounding boxes to transform. |
imagelist[ | Original image shapes. |
xint | X-coordinate of the crop start point. |
yint | Y-coordinate of the crop start point. |
| **_ | Undocumented |
| Returns | |
np.ndarray | Transformed bounding boxes. |
list[ np.ndarray], x_crop: int, y_crop: int, **_) -> np.ndarray:
¶
Apply mosaic augmentation 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. |
xint | X-coordinate of the crop start point. |
yint | Y-coordinate of the crop start point. |
| **_ | Undocumented |
| Returns | |
np.ndarray | A single instance masks of shape (Hout, Wout, N). |
list[ np.ndarray], image_shapes: list[ tuple[ int, int]], x_crop: int, y_crop: int, **_) -> np.ndarray:
¶
Apply mosaic augmentation to a batch of keypoints.
| Parameters | |
keypointslist[ | Keypoints to transform. |
imagelist[ | Original image shapes. |
xint | X-coordinate of the crop start point. |
yint | Y-coordinate of the crop start point. |
| **_ | Undocumented |
| Returns | |
np.ndarray | Transformed keypoints. |
list[ np.ndarray], x_crop: int, y_crop: int, out_height: int, out_width: int, **_) -> np.ndarray:
¶
Apply mosaic augmentation to a batch of semantic segmentation masks.
| Parameters | |
masklist[ | Masks to transform. Each mask should be of shape (H, W, C) or (H, W). |
xint | X-coordinate of the crop start point. |
yint | Y-coordinate of the crop start point. |
outint | The expected height of the output mask. |
outint | The expected width of the output mask. |
| **_ | Undocumented |
| Returns | |
np.ndarray | A single segmentation mask of shape (Hout, Wout, C) or (Hout, Wout). |
dict[ str, Any], data: dict[ str, Any]) -> dict[ str, Any]:
¶
Get parameters dependent on the targets.
| Parameters | |
params:dict[ | Existing augmentation parameters. |
data:dict[ | Input data. |
| Returns | |
dict[ | Parameters derived from the input targets. |
np.ndarray, in_height: int, in_width: int, position_index: int, out_height: int, out_width: int, x_crop: int, y_crop: int) -> np.ndarray:
¶
Adjust bounding box coordinates for the mosaic grid position.
list[ np.ndarray], out_height: int, out_width: int, x_crop: int, y_crop: int, padding: float | list[ int] | list[ float] | None = None) -> np.ndarray:
¶
Arrange the images in a 2×2 grid layout.
The input images should have the same number of channels but can have different widths and heights. The gaps are filled by the padding value.
list[ np.ndarray], out_height: int, out_width: int, x_crop: int, y_crop: int, value: float | list[ int] | list[ float] | None = None) -> np.ndarray:
¶
Undocumented
np.ndarray, in_height: int, in_width: int, position_index: int, out_height: int, out_width: int, x_crop: int, y_crop: int) -> np.ndarray:
¶
Adjust keypoint coordinates for the mosaic grid position.
int, out_height: int, out_width: int, in_height: int, in_width: int) -> tuple[ tuple[ int, int, int, int], tuple[ int, int, int, int]]:
¶
Undocumented
int, in_height: int, in_width: int, out_height: int, out_width: int) -> tuple[ int, int]:
¶
Undocumented