Unverified Commit 7dc5e5bd authored by Philip Meier's avatar Philip Meier Committed by GitHub
Browse files

Fix typos and grammar errors (#7065)

* fix typos throughout the code base

* fix grammar

* revert formatting changes to gallery

* revert 'an uXX'

* remove 'number of the best'
parent ed2a0adb
...@@ -272,7 +272,7 @@ def _rgb2hsv(img: Tensor) -> Tensor: ...@@ -272,7 +272,7 @@ def _rgb2hsv(img: Tensor) -> Tensor:
# + S channel has division by `maxc`, which is zero only if `maxc = minc` # + S channel has division by `maxc`, which is zero only if `maxc = minc`
# + H channel has division by `(maxc - minc)`. # + H channel has division by `(maxc - minc)`.
# #
# Instead of overwriting NaN afterwards, we just prevent it from occuring so # Instead of overwriting NaN afterwards, we just prevent it from occurring, so
# we don't need to deal with it in case we save the NaN in a buffer in # we don't need to deal with it in case we save the NaN in a buffer in
# backprop, if it is ever supported, but it doesn't hurt to do so. # backprop, if it is ever supported, but it doesn't hurt to do so.
eqc = maxc == minc eqc = maxc == minc
...@@ -416,7 +416,7 @@ def pad( ...@@ -416,7 +416,7 @@ def pad(
out_dtype = img.dtype out_dtype = img.dtype
need_cast = False need_cast = False
if (padding_mode != "constant") and img.dtype not in (torch.float32, torch.float64): if (padding_mode != "constant") and img.dtype not in (torch.float32, torch.float64):
# Here we temporary cast input tensor to float # Here we temporarily cast input tensor to float
# until pytorch issue is resolved : # until pytorch issue is resolved :
# https://github.com/pytorch/pytorch/issues/40763 # https://github.com/pytorch/pytorch/issues/40763
need_cast = True need_cast = True
......
...@@ -304,7 +304,7 @@ class Resize(torch.nn.Module): ...@@ -304,7 +304,7 @@ class Resize(torch.nn.Module):
the resized image: if the longer edge of the image is greater the resized image: if the longer edge of the image is greater
than ``max_size`` after being resized according to ``size``, then than ``max_size`` after being resized according to ``size``, then
the image is resized again so that the longer edge is equal to the image is resized again so that the longer edge is equal to
``max_size``. As a result, ``size`` might be overruled, i.e the ``max_size``. As a result, ``size`` might be overruled, i.e. the
smaller edge may be shorter than ``size``. This is only supported smaller edge may be shorter than ``size``. This is only supported
if ``size`` is an int (or a sequence of length 1 in torchscript if ``size`` is an int (or a sequence of length 1 in torchscript
mode). mode).
...@@ -1160,7 +1160,7 @@ class ColorJitter(torch.nn.Module): ...@@ -1160,7 +1160,7 @@ class ColorJitter(torch.nn.Module):
or the given [min, max]. Should be non negative numbers. or the given [min, max]. Should be non negative numbers.
contrast (float or tuple of float (min, max)): How much to jitter contrast. contrast (float or tuple of float (min, max)): How much to jitter contrast.
contrast_factor is chosen uniformly from [max(0, 1 - contrast), 1 + contrast] contrast_factor is chosen uniformly from [max(0, 1 - contrast), 1 + contrast]
or the given [min, max]. Should be non negative numbers. or the given [min, max]. Should be non-negative numbers.
saturation (float or tuple of float (min, max)): How much to jitter saturation. saturation (float or tuple of float (min, max)): How much to jitter saturation.
saturation_factor is chosen uniformly from [max(0, 1 - saturation), 1 + saturation] saturation_factor is chosen uniformly from [max(0, 1 - saturation), 1 + saturation]
or the given [min, max]. Should be non negative numbers. or the given [min, max]. Should be non negative numbers.
...@@ -1381,10 +1381,10 @@ class RandomAffine(torch.nn.Module): ...@@ -1381,10 +1381,10 @@ class RandomAffine(torch.nn.Module):
scale (tuple, optional): scaling factor interval, e.g (a, b), then scale is scale (tuple, optional): scaling factor interval, e.g (a, b), then scale is
randomly sampled from the range a <= scale <= b. Will keep original scale by default. randomly sampled from the range a <= scale <= b. Will keep original scale by default.
shear (sequence or number, optional): Range of degrees to select from. shear (sequence or number, optional): Range of degrees to select from.
If shear is a number, a shear parallel to the x axis in the range (-shear, +shear) If shear is a number, a shear parallel to the x-axis in the range (-shear, +shear)
will be applied. Else if shear is a sequence of 2 values a shear parallel to the x axis in the will be applied. Else if shear is a sequence of 2 values a shear parallel to the x-axis in the
range (shear[0], shear[1]) will be applied. Else if shear is a sequence of 4 values, range (shear[0], shear[1]) will be applied. Else if shear is a sequence of 4 values,
a x-axis shear in (shear[0], shear[1]) and y-axis shear in (shear[2], shear[3]) will be applied. an x-axis shear in (shear[0], shear[1]) and y-axis shear in (shear[2], shear[3]) will be applied.
Will not apply shear by default. Will not apply shear by default.
interpolation (InterpolationMode): Desired interpolation enum defined by interpolation (InterpolationMode): Desired interpolation enum defined by
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``. :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
...@@ -1602,7 +1602,7 @@ class RandomGrayscale(torch.nn.Module): ...@@ -1602,7 +1602,7 @@ class RandomGrayscale(torch.nn.Module):
class RandomErasing(torch.nn.Module): class RandomErasing(torch.nn.Module):
"""Randomly selects a rectangle region in an torch Tensor image and erases its pixels. """Randomly selects a rectangle region in a torch.Tensor image and erases its pixels.
This transform does not support PIL Image. This transform does not support PIL Image.
'Random Erasing Data Augmentation' by Zhong et al. See https://arxiv.org/abs/1708.04896 'Random Erasing Data Augmentation' by Zhong et al. See https://arxiv.org/abs/1708.04896
...@@ -1938,7 +1938,7 @@ class RandomAdjustSharpness(torch.nn.Module): ...@@ -1938,7 +1938,7 @@ class RandomAdjustSharpness(torch.nn.Module):
Args: Args:
sharpness_factor (float): How much to adjust the sharpness. Can be sharpness_factor (float): How much to adjust the sharpness. Can be
any non negative number. 0 gives a blurred image, 1 gives the any non-negative number. 0 gives a blurred image, 1 gives the
original image while 2 increases the sharpness by a factor of 2. original image while 2 increases the sharpness by a factor of 2.
p (float): probability of the image being sharpened. Default value is 0.5 p (float): probability of the image being sharpened. Default value is 0.5
""" """
......
...@@ -145,7 +145,7 @@ def save_image( ...@@ -145,7 +145,7 @@ def save_image(
if not torch.jit.is_scripting() and not torch.jit.is_tracing(): if not torch.jit.is_scripting() and not torch.jit.is_tracing():
_log_api_usage_once(save_image) _log_api_usage_once(save_image)
grid = make_grid(tensor, **kwargs) grid = make_grid(tensor, **kwargs)
# Add 0.5 after unnormalizing to [0, 255] to round to nearest integer # Add 0.5 after unnormalizing to [0, 255] to round to the nearest integer
ndarr = grid.mul(255).add_(0.5).clamp_(0, 255).permute(1, 2, 0).to("cpu", torch.uint8).numpy() ndarr = grid.mul(255).add_(0.5).clamp_(0, 255).permute(1, 2, 0).to("cpu", torch.uint8).numpy()
im = Image.fromarray(ndarr) im = Image.fromarray(ndarr)
im.save(fp, format=format) im.save(fp, format=format)
...@@ -565,7 +565,7 @@ def _log_api_usage_once(obj: Any) -> None: ...@@ -565,7 +565,7 @@ def _log_api_usage_once(obj: Any) -> None:
def _make_ntuple(x: Any, n: int) -> Tuple[Any, ...]: def _make_ntuple(x: Any, n: int) -> Tuple[Any, ...]:
""" """
Make n-tuple from input x. If x is an iterable, then we just convert it to tuple. Make n-tuple from input x. If x is an iterable, then we just convert it to tuple.
Otherwise we will make a tuple of length n, all with value of x. Otherwise, we will make a tuple of length n, all with value of x.
reference: https://github.com/pytorch/pytorch/blob/master/torch/nn/modules/utils.py#L8 reference: https://github.com/pytorch/pytorch/blob/master/torch/nn/modules/utils.py#L8
Args: Args:
......
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