peal.data.transformations.RandomRotation

class peal.data.transformations.RandomRotation[source]

Bases: object

Rotate a tensor image by a random integer angle.

The angle drawn for the most recent call is kept in last_theta (degrees) so that a paired transform, e.g. for a mask, can reuse it.

Parameters:
  • min_rotation (int, optional) – Smallest angle in degrees. Defaults to -180.

  • max_rotation (int, optional) – Largest angle in degrees. Defaults to 180.

Methods

__init__(min_rotation=-180, max_rotation=180)[source]

Store the angle range and initialize last_theta.

__call__(sample)[source]

Rotate sample by a uniformly drawn angle, filling with 0.5.

Parameters:

sample (torch.Tensor) – Image of shape [C, H, W].

Returns:

Rotated image of the same shape.

Return type:

torch.Tensor