pyiqa.data.transforms¶
Module Contents¶
- class pyiqa.data.transforms.PairedToTensor[source]¶
Bases:
torchvision.transforms.ToTensorPair version of to tensor
- class pyiqa.data.transforms.PairedCenterCrop[source]¶
Bases:
torchvision.transforms.CenterCropPair version of center crop
- class pyiqa.data.transforms.PairedRandomCrop[source]¶
Bases:
torchvision.transforms.RandomCropPair version of random crop
- class pyiqa.data.transforms.PairedRandomErasing[source]¶
Bases:
torchvision.transforms.RandomErasingPair version of random erasing
- class pyiqa.data.transforms.PairedRandomHorizontalFlip[source]¶
Bases:
torchvision.transforms.RandomHorizontalFlipPair version of random hflip
- class pyiqa.data.transforms.PairedRandomVerticalFlip[source]¶
Bases:
torchvision.transforms.RandomVerticalFlipPair version of random vflip
- class pyiqa.data.transforms.PairedRandomRot90(p=0.5)[source]¶
Bases:
torch.nn.ModulePair version of random 90 rotation
- class pyiqa.data.transforms.PairedResize[source]¶
Bases:
torchvision.transforms.ResizePair version of resize
- class pyiqa.data.transforms.PairedAdaptiveResize[source]¶
Bases:
torchvision.transforms.ResizeARP preserved resize when necessary
- class pyiqa.data.transforms.PairedRandomARPResize(size_range, interpolation=tf.InterpolationMode.BILINEAR, antialias=None)[source]¶
Bases:
torch.nn.ModulePair version of resize
- class pyiqa.data.transforms.PairedRandomSquareResize(size_range, interpolation=tf.InterpolationMode.BILINEAR, antialias=None)[source]¶
Bases:
torch.nn.ModulePair version of resize
- class pyiqa.data.transforms.PairedAdaptivePadding(target_size, fill=0, padding_mode='constant')[source]¶
Bases:
torch.nn.ModulePair version of resize
- 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.