Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated transforms docs #2820

Merged
merged 1 commit into from
Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 39 additions & 13 deletions docs/source/transforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,77 +57,103 @@ Compositions of transforms

.. autoclass:: Compose

Transforms on PIL Image
-----------------------
Transforms on PIL Image and torch.\*Tensor
------------------------------------------

.. autoclass:: CenterCrop
:members:

.. autoclass:: ColorJitter
:members:

.. autoclass:: FiveCrop
:members:

.. autoclass:: Grayscale
:members:

.. autoclass:: Pad
:members:

.. autoclass:: RandomAffine
:members:

.. autoclass:: RandomApply

.. autoclass:: RandomChoice

.. autoclass:: RandomCrop
:members:

.. autoclass:: RandomGrayscale
:members:

.. autoclass:: RandomHorizontalFlip

.. autoclass:: RandomOrder
:members:

.. autoclass:: RandomPerspective
:members:

.. autoclass:: RandomResizedCrop
:members:

.. autoclass:: RandomRotation
:members:

.. autoclass:: RandomSizedCrop
:members:

.. autoclass:: RandomVerticalFlip
:members:

.. autoclass:: Resize
:members:

.. autoclass:: Scale
:members:

.. autoclass:: TenCrop
:members:

.. autoclass:: GaussianBlur
:members:

Transforms on torch.\*Tensor
Transforms on PIL Image only
----------------------------

.. autoclass:: RandomChoice

.. autoclass:: RandomOrder


Transforms on torch.\*Tensor only
---------------------------------

.. autoclass:: LinearTransformation
:members:

.. autoclass:: Normalize
:members: __call__
:special-members:
:members:

.. autoclass:: RandomErasing
:members:

.. autoclass:: ConvertImageDtype


Conversion Transforms
---------------------

.. autoclass:: ToPILImage
:members: __call__
:special-members:
:members:

.. autoclass:: ToTensor
:members: __call__
:special-members:
:members:


Generic Transforms
------------------

.. autoclass:: Lambda
:members:


Functional Transforms
Expand Down
2 changes: 1 addition & 1 deletion torchvision/transforms/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Returns:
(torch.Tensor): Converted image
Tensor: Converted image
.. note::
Expand Down
22 changes: 11 additions & 11 deletions torchvision/transforms/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def __init__(self, dtype: torch.dtype) -> None:
super().__init__()
self.dtype = dtype

def forward(self, image: torch.Tensor) -> torch.Tensor:
def forward(self, image):
return F.convert_image_dtype(image, self.dtype)


Expand Down Expand Up @@ -218,7 +218,7 @@ def __init__(self, mean, std, inplace=False):
def forward(self, tensor: Tensor) -> Tensor:
"""
Args:
tensor (Tensor): Tensor image of size (C, H, W) to be normalized.
tensor (Tensor): Tensor image to be normalized.
Returns:
Tensor: Normalized Tensor image.
Expand Down Expand Up @@ -972,7 +972,7 @@ def __init__(self, transformation_matrix, mean_vector):
def forward(self, tensor: Tensor) -> Tensor:
"""
Args:
tensor (Tensor): Tensor image of size (C, H, W) to be whitened.
tensor (Tensor): Tensor image to be whitened.
Returns:
Tensor: Transformed image.
Expand Down Expand Up @@ -1342,7 +1342,7 @@ def __init__(self, num_output_channels=1):
super().__init__()
self.num_output_channels = num_output_channels

def forward(self, img: Tensor) -> Tensor:
def forward(self, img):
"""
Args:
img (PIL Image or Tensor): Image to be converted to grayscale.
Expand Down Expand Up @@ -1377,7 +1377,7 @@ def __init__(self, p=0.1):
super().__init__()
self.p = p

def forward(self, img: Tensor) -> Tensor:
def forward(self, img):
"""
Args:
img (PIL Image or Tensor): Image to be converted to grayscale.
Expand Down Expand Up @@ -1411,7 +1411,7 @@ class RandomErasing(torch.nn.Module):
Returns:
Erased Image.
# Examples:
Example:
>>> transform = transforms.Compose([
>>> transforms.RandomHorizontalFlip(),
>>> transforms.ToTensor(),
Expand Down Expand Up @@ -1450,7 +1450,7 @@ def get_params(
"""Get parameters for ``erase`` for a random erasing.
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.
ratio (tuple or list): range of aspect ratio of erased area.
value (list, optional): erasing value. If None, it is interpreted as "random"
Expand Down Expand Up @@ -1487,7 +1487,7 @@ def get_params(
def forward(self, img):
"""
Args:
img (Tensor): Tensor image of size (C, H, W) to be erased.
img (Tensor): Tensor image to be erased.
Returns:
img (Tensor): Erased Tensor image.
Expand Down Expand Up @@ -1518,7 +1518,7 @@ def forward(self, img):
class GaussianBlur(torch.nn.Module):
"""Blurs image with randomly chosen Gaussian blur.
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
Args:
Expand Down Expand Up @@ -1554,7 +1554,7 @@ def __init__(self, kernel_size, sigma=(0.1, 2.0)):

@staticmethod
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:
sigma_min (float): Minimum standard deviation that can be chosen for blurring kernel.
Expand All @@ -1568,7 +1568,7 @@ def get_params(sigma_min: float, sigma_max: float) -> float:
def forward(self, img: Tensor) -> Tensor:
"""
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:
PIL Image or Tensor: Gaussian blurred image
Expand Down