Skip to content

Transforms

eva.core.data.transforms.dtype.ArrayToTensor

Converts a numpy array to a torch tensor.

eva.core.data.transforms.dtype.ArrayToFloatTensor

Bases: ArrayToTensor

Converts a numpy array to a torch tensor and casts it to float.

eva.vision.data.transforms.ResizeAndCrop

Bases: Compose

Resizes, crops and normalizes an input image while preserving its aspect ratio.

Parameters:

Name Type Description Default
size int | Sequence[int]

Desired output size of the crop. If size is an int instead of sequence like (h, w), a square crop (size, size) is made.

224
mean Sequence[float]

Sequence of means for each image channel.

(0.5, 0.5, 0.5)
std Sequence[float]

Sequence of standard deviations for each image channel.

(0.5, 0.5, 0.5)
Source code in src/eva/vision/data/transforms/common/resize_and_crop.py
def __init__(
    self,
    size: int | Sequence[int] = 224,
    mean: Sequence[float] = (0.5, 0.5, 0.5),
    std: Sequence[float] = (0.5, 0.5, 0.5),
) -> None:
    """Initializes the transform object.

    Args:
        size: Desired output size of the crop. If size is an `int` instead
            of sequence like (h, w), a square crop (size, size) is made.
        mean: Sequence of means for each image channel.
        std: Sequence of standard deviations for each image channel.
    """
    self._size = size
    self._mean = mean
    self._std = std

    super().__init__(transforms=self._build_transforms())