pyiqa.data.transforms ===================== .. py:module:: pyiqa.data.transforms Module Contents --------------- .. py:function:: transform_mapping(key, args) .. py:class:: PairedToTensor Bases: :py:obj:`torchvision.transforms.ToTensor` Pair version of to tensor .. py:method:: to_tensor(x) .. py:class:: PairedCenterCrop Bases: :py:obj:`torchvision.transforms.CenterCrop` Pair version of center crop .. py:method:: forward(imgs) .. py:class:: PairedRandomCrop Bases: :py:obj:`torchvision.transforms.RandomCrop` Pair version of random crop .. py:method:: forward(imgs) .. py:class:: PairedRandomErasing Bases: :py:obj:`torchvision.transforms.RandomErasing` Pair version of random erasing .. py:method:: forward(imgs) .. py:class:: PairedRandomHorizontalFlip Bases: :py:obj:`torchvision.transforms.RandomHorizontalFlip` Pair version of random hflip .. py:method:: forward(imgs) .. py:class:: PairedRandomVerticalFlip Bases: :py:obj:`torchvision.transforms.RandomVerticalFlip` Pair version of random vflip .. py:method:: forward(imgs) .. py:class:: PairedRandomRot90(p=0.5) Bases: :py:obj:`torch.nn.Module` Pair version of random 90 rotation .. py:method:: forward(imgs) .. py:class:: PairedResize Bases: :py:obj:`torchvision.transforms.Resize` Pair version of resize .. py:method:: forward(imgs) .. py:class:: PairedAdaptiveResize Bases: :py:obj:`torchvision.transforms.Resize` ARP preserved resize when necessary .. py:method:: forward(imgs) .. py:class:: PairedRandomARPResize(size_range, interpolation=tf.InterpolationMode.BILINEAR, antialias=None) Bases: :py:obj:`torch.nn.Module` Pair version of resize .. py:method:: forward(imgs) .. py:class:: PairedRandomSquareResize(size_range, interpolation=tf.InterpolationMode.BILINEAR, antialias=None) Bases: :py:obj:`torch.nn.Module` Pair version of resize .. py:method:: forward(imgs) .. py:class:: PairedAdaptivePadding(target_size, fill=0, padding_mode='constant') Bases: :py:obj:`torch.nn.Module` Pair version of resize .. py:method:: get_padding(x) .. py:method:: forward(imgs) .. py:function:: mod_crop(img, scale) Mod crop images, used during testing. :param img: Input image. :type img: ndarray :param scale: Scale factor. :type scale: int :returns: Result image. :rtype: ndarray .. py:function:: augment(imgs, hflip=True, rotation=True, flows=None, return_status=False) 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. :param imgs: Images to be augmented. If the input is an ndarray, it will be transformed to a list. :type imgs: list[ndarray] | ndarray :param hflip: Horizontal flip. Default: True. :type hflip: bool :param rotation: Ratotation. Default: True. :type rotation: bool :param flows (list[ndarray]: Flows to be augmented. If the input is an ndarray, it will be transformed to a list. Dimension is (h, w, 2). Default: None. :param return_status: Return the status of flip and rotation. Default: False. :type return_status: bool :returns: Augmented images and flows. If returned results only have one element, just return ndarray. :rtype: list[ndarray] | ndarray .. py:function:: img_rotate(img, angle, center=None, scale=1.0) Rotate image. :param img: Image to be rotated. :type img: ndarray :param angle: Rotation angle in degrees. Positive values mean counter-clockwise rotation. :type angle: float :param center: Rotation center. If the center is None, initialize it as the center of the image. Default: None. :type center: tuple[int] :param scale: Isotropic scale factor. Default: 1.0. :type scale: float