yamle.data.transforms module#

class yamle.data.transforms.JointCompose(transforms)[source]#

Bases: Compose

This class is a wrapper for the torchvision Compose class, which applies transformations to both the data and the target.

Parameters:

transforms (List[Callable]) – List of transformations to apply to the data and the target.

class yamle.data.transforms.FromOneHot[source]#

Bases: object

This class converts one-hot encoded targets to class labels.

class yamle.data.transforms.JointResize(height, width)[source]#

Bases: object

Perform resizing if the input is larger or smaller than the limiting height/width.

The input is interpolated using the bilinear interpolation method. The target is interpolated using the nearest neighbour interpolation method.

Parameters:
  • height (int) – The limiting height.

  • width (int) – The limiting width.

class yamle.data.transforms.JointCenterCrop(height, width)[source]#

Bases: object

Perform center cropping if the input is larger than the limiting height/width.

Parameters:
  • height (int) – The limiting height.

  • width (int) – The limiting width.

class yamle.data.transforms.JointNormalize(mean, std)[source]#

Bases: object

Perform normalization on the input and leave the target unchanged.

Parameters:
  • mean (Tuple[float, float, float]) – Mean values for each channel.

  • std (Tuple[float, float, float]) – Standard deviation values for each channel.

class yamle.data.transforms.JointToTensor(img_dtype=torch.float32, target_dtype=torch.int64)[source]#

Bases: object

Convert the input and target to tensors.

Parameters:
  • img_dtype (torch.dtype) – The data type of the input. Default: torch.float32.

  • target_dtype (torch.dtype) – The data type of the target. Default: torch.long.

class yamle.data.transforms.JointTargetSqueeze(dim)[source]#

Bases: object

Squeeze the target tensor.

Parameters:

dim (int) – The dimension to squeeze.

class yamle.data.transforms.TargetToUnit(scale=1.0)[source]#

Bases: object

Converts the target image to meters.

Parameters:

scale (float) – Scale factor to convert the target image.

class yamle.data.transforms.ClassificationDatasetSubset(dataset, indices)[source]#

Bases: object

This class takes a subset of a dataset specified by a list of indices corresponding to the subset of the classes.

It creates a Subset object from the torch.utils.data package. It goes through the entire dataset and checks which indices correspond to the subset of the classes. It then creates a list of indices corresponding to the subset. Finally, it creates a Subset object from the dataset and the list of indices.

Parameters:
  • dataset (torch.utils.data.Dataset) – The dataset to take a subset of.

  • indices (List[int]) – The indices of the subset of classes.

class yamle.data.transforms.Normalize(mean, std)[source]#

Bases: object

This class normalizes the data and targets to zero mean and unit variance, given the mean and standard deviation of the training data.

Parameters:
  • mean (torch.Tensor) – Mean of the training data.

  • std (torch.Tensor) – Standard deviation of the training data.

inverse(data)[source]#

Inverse normalization.

Parameters:

data (torch.Tensor) – Data to inverse normalize.

Return type:

Tensor

class yamle.data.transforms.Denormalize(mean, std)[source]#

Bases: object

Denormalize the input image.

Parameters:
  • mean (Tuple[float, float, float]) – Mean values for each channel.

  • std (Tuple[float, float, float]) – Standard deviation values for each channel.