Unverified Commit a0559803 authored by vfdev's avatar vfdev Committed by GitHub
Browse files

Updated transforms docs (#2820)

parent adfc15c4
...@@ -57,77 +57,103 @@ Compositions of transforms ...@@ -57,77 +57,103 @@ Compositions of transforms
.. autoclass:: Compose .. autoclass:: Compose
Transforms on PIL Image Transforms on PIL Image and torch.\*Tensor
----------------------- ------------------------------------------
.. autoclass:: CenterCrop .. autoclass:: CenterCrop
:members:
.. autoclass:: ColorJitter .. autoclass:: ColorJitter
:members:
.. autoclass:: FiveCrop .. autoclass:: FiveCrop
:members:
.. autoclass:: Grayscale .. autoclass:: Grayscale
:members:
.. autoclass:: Pad .. autoclass:: Pad
:members:
.. autoclass:: RandomAffine .. autoclass:: RandomAffine
:members:
.. autoclass:: RandomApply .. autoclass:: RandomApply
.. autoclass:: RandomChoice
.. autoclass:: RandomCrop .. autoclass:: RandomCrop
:members:
.. autoclass:: RandomGrayscale .. autoclass:: RandomGrayscale
:members:
.. autoclass:: RandomHorizontalFlip .. autoclass:: RandomHorizontalFlip
:members:
.. autoclass:: RandomOrder
.. autoclass:: RandomPerspective .. autoclass:: RandomPerspective
:members:
.. autoclass:: RandomResizedCrop .. autoclass:: RandomResizedCrop
:members:
.. autoclass:: RandomRotation .. autoclass:: RandomRotation
:members:
.. autoclass:: RandomSizedCrop .. autoclass:: RandomSizedCrop
:members:
.. autoclass:: RandomVerticalFlip .. autoclass:: RandomVerticalFlip
:members:
.. autoclass:: Resize .. autoclass:: Resize
:members:
.. autoclass:: Scale .. autoclass:: Scale
:members:
.. autoclass:: TenCrop .. autoclass:: TenCrop
:members:
.. autoclass:: GaussianBlur .. autoclass:: GaussianBlur
:members:
Transforms on torch.\*Tensor Transforms on PIL Image only
---------------------------- ----------------------------
.. autoclass:: RandomChoice
.. autoclass:: RandomOrder
Transforms on torch.\*Tensor only
---------------------------------
.. autoclass:: LinearTransformation .. autoclass:: LinearTransformation
:members:
.. autoclass:: Normalize .. autoclass:: Normalize
:members: __call__ :members:
:special-members:
.. autoclass:: RandomErasing .. autoclass:: RandomErasing
:members:
.. autoclass:: ConvertImageDtype
Conversion Transforms Conversion Transforms
--------------------- ---------------------
.. autoclass:: ToPILImage .. autoclass:: ToPILImage
:members: __call__ :members:
:special-members:
.. autoclass:: ToTensor .. autoclass:: ToTensor
:members: __call__ :members:
:special-members:
Generic Transforms Generic Transforms
------------------ ------------------
.. autoclass:: Lambda .. autoclass:: Lambda
:members:
Functional Transforms Functional Transforms
......
...@@ -139,7 +139,7 @@ def convert_image_dtype(image: torch.Tensor, dtype: torch.dtype = torch.float) - ...@@ -139,7 +139,7 @@ def convert_image_dtype(image: torch.Tensor, dtype: torch.dtype = torch.float) -
dtype (torch.dtype): Desired data type of the output dtype (torch.dtype): Desired data type of the output
Returns: Returns:
(torch.Tensor): Converted image Tensor: Converted image
.. note:: .. note::
......
...@@ -149,7 +149,7 @@ class ConvertImageDtype(torch.nn.Module): ...@@ -149,7 +149,7 @@ class ConvertImageDtype(torch.nn.Module):
super().__init__() super().__init__()
self.dtype = dtype self.dtype = dtype
def forward(self, image: torch.Tensor) -> torch.Tensor: def forward(self, image):
return F.convert_image_dtype(image, self.dtype) return F.convert_image_dtype(image, self.dtype)
...@@ -218,7 +218,7 @@ class Normalize(torch.nn.Module): ...@@ -218,7 +218,7 @@ class Normalize(torch.nn.Module):
def forward(self, tensor: Tensor) -> Tensor: def forward(self, tensor: Tensor) -> Tensor:
""" """
Args: Args:
tensor (Tensor): Tensor image of size (C, H, W) to be normalized. tensor (Tensor): Tensor image to be normalized.
Returns: Returns:
Tensor: Normalized Tensor image. Tensor: Normalized Tensor image.
...@@ -972,7 +972,7 @@ class LinearTransformation(torch.nn.Module): ...@@ -972,7 +972,7 @@ class LinearTransformation(torch.nn.Module):
def forward(self, tensor: Tensor) -> Tensor: def forward(self, tensor: Tensor) -> Tensor:
""" """
Args: Args:
tensor (Tensor): Tensor image of size (C, H, W) to be whitened. tensor (Tensor): Tensor image to be whitened.
Returns: Returns:
Tensor: Transformed image. Tensor: Transformed image.
...@@ -1342,7 +1342,7 @@ class Grayscale(torch.nn.Module): ...@@ -1342,7 +1342,7 @@ class Grayscale(torch.nn.Module):
super().__init__() super().__init__()
self.num_output_channels = num_output_channels self.num_output_channels = num_output_channels
def forward(self, img: Tensor) -> Tensor: def forward(self, img):
""" """
Args: Args:
img (PIL Image or Tensor): Image to be converted to grayscale. img (PIL Image or Tensor): Image to be converted to grayscale.
...@@ -1377,7 +1377,7 @@ class RandomGrayscale(torch.nn.Module): ...@@ -1377,7 +1377,7 @@ class RandomGrayscale(torch.nn.Module):
super().__init__() super().__init__()
self.p = p self.p = p
def forward(self, img: Tensor) -> Tensor: def forward(self, img):
""" """
Args: Args:
img (PIL Image or Tensor): Image to be converted to grayscale. img (PIL Image or Tensor): Image to be converted to grayscale.
...@@ -1411,7 +1411,7 @@ class RandomErasing(torch.nn.Module): ...@@ -1411,7 +1411,7 @@ class RandomErasing(torch.nn.Module):
Returns: Returns:
Erased Image. Erased Image.
# Examples: Example:
>>> transform = transforms.Compose([ >>> transform = transforms.Compose([
>>> transforms.RandomHorizontalFlip(), >>> transforms.RandomHorizontalFlip(),
>>> transforms.ToTensor(), >>> transforms.ToTensor(),
...@@ -1450,7 +1450,7 @@ class RandomErasing(torch.nn.Module): ...@@ -1450,7 +1450,7 @@ class RandomErasing(torch.nn.Module):
"""Get parameters for ``erase`` for a random erasing. """Get parameters for ``erase`` for a random erasing.
Args: Args:
img (Tensor): Tensor image of size (C, H, W) to be erased. img (Tensor): Tensor image to be erased.
scale (tuple or list): range of proportion of erased area against input image. scale (tuple or list): range of proportion of erased area against input image.
ratio (tuple or list): range of aspect ratio of erased area. ratio (tuple or list): range of aspect ratio of erased area.
value (list, optional): erasing value. If None, it is interpreted as "random" value (list, optional): erasing value. If None, it is interpreted as "random"
...@@ -1487,7 +1487,7 @@ class RandomErasing(torch.nn.Module): ...@@ -1487,7 +1487,7 @@ class RandomErasing(torch.nn.Module):
def forward(self, img): def forward(self, img):
""" """
Args: Args:
img (Tensor): Tensor image of size (C, H, W) to be erased. img (Tensor): Tensor image to be erased.
Returns: Returns:
img (Tensor): Erased Tensor image. img (Tensor): Erased Tensor image.
...@@ -1518,7 +1518,7 @@ class RandomErasing(torch.nn.Module): ...@@ -1518,7 +1518,7 @@ class RandomErasing(torch.nn.Module):
class GaussianBlur(torch.nn.Module): class GaussianBlur(torch.nn.Module):
"""Blurs image with randomly chosen Gaussian blur. """Blurs image with randomly chosen Gaussian blur.
The image can be a PIL Image or a Tensor, in which case it is expected The image can be a PIL Image or a Tensor, in which case it is expected
to have [..., 3, H, W] shape, where ... means an arbitrary number of leading to have [..., C, H, W] shape, where ... means an arbitrary number of leading
dimensions dimensions
Args: Args:
...@@ -1554,7 +1554,7 @@ class GaussianBlur(torch.nn.Module): ...@@ -1554,7 +1554,7 @@ class GaussianBlur(torch.nn.Module):
@staticmethod @staticmethod
def get_params(sigma_min: float, sigma_max: float) -> float: def get_params(sigma_min: float, sigma_max: float) -> float:
"""Choose sigma for ``gaussian_blur`` for random gaussian blurring. """Choose sigma for random gaussian blurring.
Args: Args:
sigma_min (float): Minimum standard deviation that can be chosen for blurring kernel. sigma_min (float): Minimum standard deviation that can be chosen for blurring kernel.
...@@ -1568,7 +1568,7 @@ class GaussianBlur(torch.nn.Module): ...@@ -1568,7 +1568,7 @@ class GaussianBlur(torch.nn.Module):
def forward(self, img: Tensor) -> Tensor: def forward(self, img: Tensor) -> Tensor:
""" """
Args: Args:
img (PIL Image or Tensor): image of size (C, H, W) to be blurred. img (PIL Image or Tensor): image to be blurred.
Returns: Returns:
PIL Image or Tensor: Gaussian blurred image PIL Image or Tensor: Gaussian blurred image
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment