minerva.transforms.transform

Classes

CastTo

Cast the input data to the specified data type.

Flip

Flip the input data along the specified axis.

Padding

This class is a base class for all transforms. Transforms is just a

PerlinMasker

Zeroes entries of a tensor according to the sign of Perlin noise. Seed for the noise generator given by torch.randint

Squeeze

Remove single-dimensional entries from the shape of an array.

TransformPipeline

Apply a sequence of transforms to a single sample of data and return the

Unsqueeze

Add a new axis to the input data at the specified position.

_Transform

This class is a base class for all transforms. Transforms is just a

Module Contents

class minerva.transforms.transform.CastTo(dtype)

Bases: _Transform

Cast the input data to the specified data type.

Cast the input data to the specified data type.

Parameters

dtypetype

The data type to which the input data will be cast.

__call__(x)

Cast the input data to the specified data type.

Parameters:

x (numpy.ndarray)

Return type:

numpy.ndarray

Parameters:

dtype (type | str)

class minerva.transforms.transform.Flip(axis=0)

Bases: _Transform

Flip the input data along the specified axis.

Flip the input data along the specified axis.

Parameters

axisint | List[int], optional

One or more axis to flip the input data along, by default 0. If a list of axis is provided, the input data is flipped along all the specified axis in the order they are provided.

__call__(x)

Flip the input data along the specified axis. if axis is an integer, the input data is flipped along the specified axis. if axis is a list of integers, the input data is flipped along all the specified axis in the order they are provided. The input must have the same, or less, number of dimensions as the length of the list of axis.

Parameters:

x (numpy.ndarray)

Return type:

numpy.ndarray

Parameters:

axis (int | List[int])

class minerva.transforms.transform.Padding(target_h_size, target_w_size)

Bases: _Transform

This class is a base class for all transforms. Transforms is just a fancy word for a function that takes an input and returns an output. The input and output can be anything. However, transforms operates over a single sample of data and does not require any additional information to perform the transformation. The __call__ method should be overridden in subclasses to define the transformation logic.

Parameters:
  • target_h_size (int)

  • target_w_size (int)

__call__(x)

Implement the transformation logic in this method. Usually, the transformation is applyied on a single sample of data.

Parameters:

x (numpy.ndarray)

Return type:

numpy.ndarray

class minerva.transforms.transform.PerlinMasker(octaves, scale=1)

Bases: _Transform

Zeroes entries of a tensor according to the sign of Perlin noise. Seed for the noise generator given by torch.randint

Zeroes entries of a tensor according to the sign of Perlin noise. Seed for the noise generator given by torch.randint

Parameters

octaves: int

Level of detail for the Perlin noise generator

scale: float = 1

Optionally rescale the Perlin noise. Default is 1 (no rescaling)

__call__(x)

Zeroes entries of a tensor according to the sign of Perlin noise.

Parameters

x: np.ndarray

The tensor whose entries to zero.

Parameters:

x (numpy.ndarray)

Return type:

numpy.ndarray

Parameters:
  • octaves (int)

  • scale (float)

class minerva.transforms.transform.Squeeze(axis)

Bases: _Transform

Remove single-dimensional entries from the shape of an array.

Remove single-dimensional entries from the shape of an array.

Parameters

axisint

The position of the axis to be removed.

__call__(x)

Remove single-dimensional entries from the shape of an array.

Parameters:

x (numpy.ndarray)

Return type:

numpy.ndarray

Parameters:

axis (int)

class minerva.transforms.transform.TransformPipeline(transforms)

Bases: _Transform

Apply a sequence of transforms to a single sample of data and return the transformed data.

Apply a sequence of transforms to a single sample of data and return the transformed data.

Parameters

transformsList[_Transform]

A list of transforms to be applied to the input data.

__call__(x)

Apply a sequence of transforms to a single sample of data and return the transformed data.

Parameters:

x (Any)

Return type:

Any

Parameters:

transforms (Sequence[_Transform])

class minerva.transforms.transform.Unsqueeze(axis)

Bases: _Transform

Add a new axis to the input data at the specified position.

Add a new axis to the input data at the specified position.

Parameters

axisint

The position of the new axis to be added.

__call__(x)

Add a new axis to the input data at the specified position.

Parameters:

x (numpy.ndarray)

Return type:

numpy.ndarray

Parameters:

axis (int)

class minerva.transforms.transform._Transform

This class is a base class for all transforms. Transforms is just a fancy word for a function that takes an input and returns an output. The input and output can be anything. However, transforms operates over a single sample of data and does not require any additional information to perform the transformation. The __call__ method should be overridden in subclasses to define the transformation logic.

abstract __call__(*args, **kwargs)

Implement the transformation logic in this method. Usually, the transformation is applyied on a single sample of data.

Return type:

Any