# batch_transform

Python API: `luxonis_ml.data.augmentations.batch_transform`

## Classes

### BatchTransform

Base class for transforms that combine multiple samples.

#### Methods

##### init

```python
def __init__(batch_size: int, **kwargs):
```

Create a batch transformation.

Batch transformations combine multiple images and their labels into one sample.

Parameters

 * `batch_size` (`int`): Number of samples required by the augmentation.
 * `**kwargs`: Additional arguments passed to the parent Albumentations transform.

##### apply

```python
def apply(image_batch: list[np.ndarray], **kwargs) -> np.ndarray:
```

Apply the transformation 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).
 * `**kwargs`: Additional implementation-specific arguments.

Returns

 * `np.ndarray`: Single transformed image resulting from the combination of the input batch.

##### apply_to_array

```python
def apply_to_array(array_batch: list[np.ndarray], **kwargs) -> np.ndarray:
```

Apply the transformation to a batch of generic arrays.

> **Note**
> The default implementation simply concatenates non-empty arrays. Override this method if a different behavior is desired.

Parameters

 * `array_batch` (`list[np.ndarray]`): A batch of arrays to transform.
 * `**kwargs`: Additional implementation-specific arguments.

Returns

 * `np.ndarray`

##### apply_to_bboxes

```python
def apply_to_bboxes(bboxes_batch: list[np.ndarray], **kwargs) -> np.ndarray:
```

Apply the transformation to a batch of bounding boxes.

Parameters

 * `bboxes_batch` (`list[np.ndarray]`): A batch of bounding boxes to transform.
 * `**kwargs`: Additional implementation-specific arguments.

Returns

 * `np.ndarray`: Transformed bounding boxes resulting from the combination of the input batch.

##### apply_to_classification

```python
def apply_to_classification(classification_batch: list[np.ndarray], **kwargs) -> np.ndarray:
```

Apply the transformation to a batch of classification labels.

> **Note**
> The default implementation treats classification labels as binary and returns their logical OR. Override this method if a different behavior is desired.

Parameters

 * `classification_batch` (`list[np.ndarray]`): A batch of classification labels to transform.
 * `**kwargs`: Additional implementation-specific arguments.

Returns

 * `np.ndarray`

##### apply_to_instance_mask

```python
def apply_to_instance_mask(masks_batch: list[np.ndarray], **kwargs) -> np.ndarray:
```

Apply the transformation 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.
 * `**kwargs`: Additional implementation-specific arguments.

Returns

 * `np.ndarray`: A single instance masks of shape (Hout, Wout, N).

##### apply_to_keypoints

```python
def apply_to_keypoints(keypoints_batch: list[np.ndarray], **kwargs) -> np.ndarray:
```

Apply the transformation to a batch of keypoints.

Parameters

 * `keypoints_batch` (`list[np.ndarray]`): A batch of keypoints to transform.
 * `**kwargs`: Additional implementation-specific arguments.

Returns

 * `np.ndarray`: Transformed keypoints resulting from the combination of the input batch.

##### apply_to_mask

```python
def apply_to_mask(masks_batch: list[np.ndarray], **kwargs) -> np.ndarray:
```

Apply the transformation to a batch of semantic segmentation masks.

Parameters

 * `masks_batch` (`list[np.ndarray]`): Masks to transform. Each mask should be of shape (H, W, C) or (H, W).
 * `**kwargs`: Additional implementation-specific arguments.

Returns

 * `np.ndarray`: Single transformed mask resulting from the combination of the input batch.

##### apply_to_metadata

```python
def apply_to_metadata(metadata_batch: list[np.ndarray], **kwargs) -> np.ndarray:
```

Apply the transformation to a batch of metadata arrays.

> **Note**
> The default implementation concatenates non-empty metadata arrays. Override this method if a different behavior is desired.

Parameters

 * `metadata_batch` (`list[np.ndarray]`): A batch of metadata arrays to transform.
 * `**kwargs`: Additional implementation-specific arguments.

Returns

 * `np.ndarray`

##### update_transform_params

```python
def update_transform_params(params: dict[str, Any], data: dict[str, Any]) -> dict[str, Any]:
```

Update the parameters dictionary with the shape of the input images.

Parameters

 * `params` (`dict[str, Any]`): Parameters to be updated
 * `data` (`dict[str, Any]`): Input data dictionary containing images/volumes

Returns

 * `dict[str, Any]`: Updated parameters dictionary with shape and transform-specific parameters.

#### Attributes

##### batch_size

Number of samples consumed by one application of the transform.

##### targets
