Unverified Commit dcfcc867 authored by Francisco Massa's avatar Francisco Massa Committed by GitHub
Browse files

Fix docstring formatting issues (#2049)



Summary: Fix docstring formatting issues

Reviewed By: fmassa

Differential Revision: D20736644

fbshipit-source-id: 78f66045cfd4c84cb35ca84a1e1fa6aadcd50642
Co-authored-by: default avatarPatrick Labatut <plabatut@fb.com>
parent ccd797dd
...@@ -51,9 +51,9 @@ def set_video_backend(backend): ...@@ -51,9 +51,9 @@ def set_video_backend(backend):
backend (string): Name of the video backend. one of {'pyav', 'video_reader'}. backend (string): Name of the video backend. one of {'pyav', 'video_reader'}.
The :mod:`pyav` package uses the 3rd party PyAv library. It is a Pythonic The :mod:`pyav` package uses the 3rd party PyAv library. It is a Pythonic
binding for the FFmpeg libraries. binding for the FFmpeg libraries.
The :mod:`video_reader` package includes a native c++ implementation on The :mod:`video_reader` package includes a native C++ implementation on
top of FFMPEG libraries, and a python API of TorchScript custom operator. top of FFMPEG libraries, and a python API of TorchScript custom operator.
It is generally decoding faster than pyav, but perhaps is less robust. It is generally decoding faster than :mod:`pyav`, but perhaps is less robust.
""" """
global _video_backend global _video_backend
if backend not in ["pyav", "video_reader"]: if backend not in ["pyav", "video_reader"]:
......
...@@ -349,6 +349,7 @@ def crop(img, top, left, height, width): ...@@ -349,6 +349,7 @@ def crop(img, top, left, height, width):
left (int): Horizontal component of the top left corner of the crop box. left (int): Horizontal component of the top left corner of the crop box.
height (int): Height of the crop box. height (int): Height of the crop box.
width (int): Width of the crop box. width (int): Width of the crop box.
Returns: Returns:
PIL Image: Cropped image. PIL Image: Cropped image.
""" """
...@@ -554,7 +555,8 @@ def five_crop(img, size): ...@@ -554,7 +555,8 @@ def five_crop(img, size):
def ten_crop(img, size, vertical_flip=False): def ten_crop(img, size, vertical_flip=False):
r"""Crop the given PIL Image into four corners and the central crop plus the """Generate ten cropped images from the given PIL Image.
Crop the given PIL Image into four corners and the central crop plus the
flipped version of these (horizontal flipping is used by default). flipped version of these (horizontal flipping is used by default).
.. Note:: .. Note::
...@@ -569,8 +571,8 @@ def ten_crop(img, size, vertical_flip=False): ...@@ -569,8 +571,8 @@ def ten_crop(img, size, vertical_flip=False):
Returns: Returns:
tuple: tuple (tl, tr, bl, br, center, tl_flip, tr_flip, bl_flip, br_flip, center_flip) tuple: tuple (tl, tr, bl, br, center, tl_flip, tr_flip, bl_flip, br_flip, center_flip)
Corresponding top left, top right, bottom left, bottom right and center crop Corresponding top left, top right, bottom left, bottom right and
and same for the flipped image. center crop and same for the flipped image.
""" """
if isinstance(size, numbers.Number): if isinstance(size, numbers.Number):
size = (int(size), int(size)) size = (int(size), int(size))
......
...@@ -641,7 +641,7 @@ class RandomResizedCrop(object): ...@@ -641,7 +641,7 @@ class RandomResizedCrop(object):
width, height = _get_image_size(img) width, height = _get_image_size(img)
area = height * width area = height * width
for attempt in range(10): for _ in range(10):
target_area = random.uniform(*scale) * area target_area = random.uniform(*scale) * area
log_ratio = (math.log(ratio[0]), math.log(ratio[1])) log_ratio = (math.log(ratio[0]), math.log(ratio[1]))
aspect_ratio = math.exp(random.uniform(*log_ratio)) aspect_ratio = math.exp(random.uniform(*log_ratio))
...@@ -1150,8 +1150,8 @@ class Grayscale(object): ...@@ -1150,8 +1150,8 @@ class Grayscale(object):
Returns: Returns:
PIL Image: Grayscale version of the input. PIL Image: Grayscale version of the input.
- If num_output_channels == 1 : returned image is single channel - If ``num_output_channels == 1`` : returned image is single channel
- If num_output_channels == 3 : returned image is 3 channel with r == g == b - If ``num_output_channels == 3`` : returned image is 3 channel with r == g == b
""" """
...@@ -1208,8 +1208,8 @@ class RandomGrayscale(object): ...@@ -1208,8 +1208,8 @@ class RandomGrayscale(object):
class RandomErasing(object): class RandomErasing(object):
""" Randomly selects a rectangle region in an image and erases its pixels. """ Randomly selects a rectangle region in an image and erases its pixels.
'Random Erasing Data Augmentation' by Zhong et al. 'Random Erasing Data Augmentation' by Zhong et al. See https://arxiv.org/pdf/1708.04896.pdf
See https://arxiv.org/pdf/1708.04896.pdf
Args: Args:
p: probability that the random erasing operation will be performed. p: probability that the random erasing operation will be performed.
scale: range of proportion of erased area against input image. scale: range of proportion of erased area against input image.
...@@ -1222,6 +1222,7 @@ class RandomErasing(object): ...@@ -1222,6 +1222,7 @@ class RandomErasing(object):
Returns: Returns:
Erased Image. Erased Image.
# Examples: # Examples:
>>> transform = transforms.Compose([ >>> transform = transforms.Compose([
>>> transforms.RandomHorizontalFlip(), >>> transforms.RandomHorizontalFlip(),
...@@ -1261,7 +1262,7 @@ class RandomErasing(object): ...@@ -1261,7 +1262,7 @@ class RandomErasing(object):
img_c, img_h, img_w = img.shape img_c, img_h, img_w = img.shape
area = img_h * img_w area = img_h * img_w
for attempt in range(10): for _ in range(10):
erase_area = random.uniform(scale[0], scale[1]) * area erase_area = random.uniform(scale[0], scale[1]) * area
aspect_ratio = random.uniform(ratio[0], ratio[1]) aspect_ratio = random.uniform(ratio[0], ratio[1])
......
...@@ -95,7 +95,7 @@ def save_image(tensor, fp, nrow=8, padding=2, ...@@ -95,7 +95,7 @@ def save_image(tensor, fp, nrow=8, padding=2,
Args: Args:
tensor (Tensor or list): Image to be saved. If given a mini-batch tensor, tensor (Tensor or list): Image to be saved. If given a mini-batch tensor,
saves the tensor as a grid of images by calling ``make_grid``. saves the tensor as a grid of images by calling ``make_grid``.
fp - A filename(string) or file object fp (string or file object): A filename or a file object
format(Optional): If omitted, the format to use is determined from the filename extension. format(Optional): If omitted, the format to use is determined from the filename extension.
If a file object was used instead of a filename, this parameter should always be used. If a file object was used instead of a filename, this parameter should always be used.
**kwargs: Other arguments are documented in ``make_grid``. **kwargs: Other arguments are documented in ``make_grid``.
......
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