BatchRandomTransform#

class torchaug.batch_transforms.BatchRandomTransform(p, inplace)[source]#

Abstract class to make a base class for all batch random transforms.

Parameters:
  • p (float) – Probability to apply the transform.

  • inplace (bool) – If True, perform inplace operation to save memory and time.

abstract apply_transform(imgs)[source]#

Function to perform transformation on the batch of images.

Note

Should be overridden by subclasses.

Parameters:

imgs (Tensor) – Batch of images to transform.

Return type:

Tensor

Returns:

The transformed batch of images.

forward(imgs)[source]#

Call apply_transform() on a randomly selected sub samples of passed images.

Parameters:

imgs (Tensor) – Images to randomly transform based on p.

Return type:

Tensor

Returns:

The randomly transformed images.