pyiqa.data.transforms

Module Contents

pyiqa.data.transforms.transform_mapping(key, args)[source]
class pyiqa.data.transforms.PairedToTensor[source]

Bases: torchvision.transforms.ToTensor

Pair version of to tensor

to_tensor(x)[source]
class pyiqa.data.transforms.PairedCenterCrop[source]

Bases: torchvision.transforms.CenterCrop

Pair version of center crop

forward(imgs)[source]
class pyiqa.data.transforms.PairedRandomCrop[source]

Bases: torchvision.transforms.RandomCrop

Pair version of random crop

forward(imgs)[source]
class pyiqa.data.transforms.PairedRandomErasing[source]

Bases: torchvision.transforms.RandomErasing

Pair version of random erasing

forward(imgs)[source]
class pyiqa.data.transforms.PairedRandomHorizontalFlip[source]

Bases: torchvision.transforms.RandomHorizontalFlip

Pair version of random hflip

forward(imgs)[source]
class pyiqa.data.transforms.PairedRandomVerticalFlip[source]

Bases: torchvision.transforms.RandomVerticalFlip

Pair version of random vflip

forward(imgs)[source]
class pyiqa.data.transforms.PairedRandomRot90(p=0.5)[source]

Bases: torch.nn.Module

Pair version of random 90 rotation

forward(imgs)[source]
class pyiqa.data.transforms.PairedResize[source]

Bases: torchvision.transforms.Resize

Pair version of resize

forward(imgs)[source]
class pyiqa.data.transforms.PairedAdaptiveResize[source]

Bases: torchvision.transforms.Resize

ARP preserved resize when necessary

forward(imgs)[source]
class pyiqa.data.transforms.PairedRandomARPResize(size_range, interpolation=tf.InterpolationMode.BILINEAR, antialias=None)[source]

Bases: torch.nn.Module

Pair version of resize

forward(imgs)[source]
class pyiqa.data.transforms.PairedRandomSquareResize(size_range, interpolation=tf.InterpolationMode.BILINEAR, antialias=None)[source]

Bases: torch.nn.Module

Pair version of resize

forward(imgs)[source]
class pyiqa.data.transforms.PairedAdaptivePadding(target_size, fill=0, padding_mode='constant')[source]

Bases: torch.nn.Module

Pair version of resize

get_padding(x)[source]
forward(imgs)[source]
pyiqa.data.transforms.mod_crop(img, scale)[source]

Mod crop images, used during testing.

Parameters:
  • img (ndarray) – Input image.

  • scale (int) – Scale factor.

Returns:

Result image.

Return type:

ndarray

pyiqa.data.transforms.augment(imgs, hflip=True, rotation=True, flows=None, return_status=False)[source]

Augment: horizontal flips OR rotate (0, 90, 180, 270 degrees).

We use vertical flip and transpose for rotation implementation. All the images in the list use the same augmentation.

Parameters:
  • imgs (list[ndarray] | ndarray) – Images to be augmented. If the input is an ndarray, it will be transformed to a list.

  • hflip (bool) – Horizontal flip. Default: True.

  • rotation (bool) – Ratotation. Default: True.

  • (list[ndarray] (flows) – Flows to be augmented. If the input is an ndarray, it will be transformed to a list. Dimension is (h, w, 2). Default: None.

  • return_status (bool) – Return the status of flip and rotation. Default: False.

Returns:

Augmented images and flows. If returned

results only have one element, just return ndarray.

Return type:

list[ndarray] | ndarray

pyiqa.data.transforms.img_rotate(img, angle, center=None, scale=1.0)[source]

Rotate image.

Parameters:
  • img (ndarray) – Image to be rotated.

  • angle (float) – Rotation angle in degrees. Positive values mean counter-clockwise rotation.

  • center (tuple[int]) – Rotation center. If the center is None, initialize it as the center of the image. Default: None.

  • scale (float) – Isotropic scale factor. Default: 1.0.