".github/vscode:/vscode.git/clone" did not exist on "5a75fa9f1a21bf981f770655df848eedd0854799"
Unverified Commit b030e936 authored by Nicolas Hug's avatar Nicolas Hug Committed by GitHub
Browse files

Change default of antialias parameter from None to 'warn' (#7160)


Co-authored-by: default avatarPhilip Meier <github.pmeier@posteo.de>
Co-authored-by: default avatarvfdev <vfdev.5@gmail.com>
parent 8fdaeb03
...@@ -306,13 +306,27 @@ class Resize(torch.nn.Module): ...@@ -306,13 +306,27 @@ class Resize(torch.nn.Module):
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).
antialias (bool, optional): antialias flag. If ``img`` is PIL Image, the flag is ignored and anti-alias antialias (bool, optional): Whether to apply antialiasing.
is always used. If ``img`` is Tensor, the flag is False by default and can be set to True for It only affects **tensors** with bilinear or bicubic modes and it is
``InterpolationMode.BILINEAR`` and ``InterpolationMode.BICUBIC`` modes. ignored otherwise: on PIL images, antialiasing is always applied on
This can help making the output for PIL images and tensors closer. bilinear or bicubic modes; on other modes (for PIL images and
tensors), antialiasing makes no sense and this parameter is ignored.
Possible values are:
- ``True``: will apply antialiasing for bilinear or bicubic modes.
Other mode aren't affected. This is probably what you want to use.
- ``False``: will not apply antialiasing for tensors on any mode. PIL
images are still antialiased on bilinear or bicubic modes, because
PIL doesn't support no antialias.
- ``None``: equivalent to ``False`` for tensors and ``True`` for
PIL images. This value exists for legacy reasons and you probably
don't want to use it unless you really know what you are doing.
The current default is ``None`` **but will change to** ``True`` **in
v0.17** for the PIL and Tensor backends to be consistent.
""" """
def __init__(self, size, interpolation=InterpolationMode.BILINEAR, max_size=None, antialias=None): def __init__(self, size, interpolation=InterpolationMode.BILINEAR, max_size=None, antialias="warn"):
super().__init__() super().__init__()
_log_api_usage_once(self) _log_api_usage_once(self)
if not isinstance(size, (int, Sequence)): if not isinstance(size, (int, Sequence)):
...@@ -847,10 +861,24 @@ class RandomResizedCrop(torch.nn.Module): ...@@ -847,10 +861,24 @@ class RandomResizedCrop(torch.nn.Module):
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.BILINEAR``. :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.BILINEAR``.
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.NEAREST_EXACT``, If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.NEAREST_EXACT``,
``InterpolationMode.BILINEAR`` and ``InterpolationMode.BICUBIC`` are supported. ``InterpolationMode.BILINEAR`` and ``InterpolationMode.BICUBIC`` are supported.
antialias (bool, optional): antialias flag. If ``img`` is PIL Image, the flag is ignored and anti-alias antialias (bool, optional): Whether to apply antialiasing.
is always used. If ``img`` is Tensor, the flag is False by default and can be set to True for It only affects **tensors** with bilinear or bicubic modes and it is
``InterpolationMode.BILINEAR`` and ``InterpolationMode.BICUBIC`` modes. ignored otherwise: on PIL images, antialiasing is always applied on
This can help making the output for PIL images and tensors closer. bilinear or bicubic modes; on other modes (for PIL images and
tensors), antialiasing makes no sense and this parameter is ignored.
Possible values are:
- ``True``: will apply antialiasing for bilinear or bicubic modes.
Other mode aren't affected. This is probably what you want to use.
- ``False``: will not apply antialiasing for tensors on any mode. PIL
images are still antialiased on bilinear or bicubic modes, because
PIL doesn't support no antialias.
- ``None``: equivalent to ``False`` for tensors and ``True`` for
PIL images. This value exists for legacy reasons and you probably
don't want to use it unless you really know what you are doing.
The current default is ``None`` **but will change to** ``True`` **in
v0.17** for the PIL and Tensor backends to be consistent.
""" """
def __init__( def __init__(
...@@ -859,7 +887,7 @@ class RandomResizedCrop(torch.nn.Module): ...@@ -859,7 +887,7 @@ class RandomResizedCrop(torch.nn.Module):
scale=(0.08, 1.0), scale=(0.08, 1.0),
ratio=(3.0 / 4.0, 4.0 / 3.0), ratio=(3.0 / 4.0, 4.0 / 3.0),
interpolation=InterpolationMode.BILINEAR, interpolation=InterpolationMode.BILINEAR,
antialias: Optional[bool] = None, antialias: Optional[Union[str, bool]] = "warn",
): ):
super().__init__() super().__init__()
_log_api_usage_once(self) _log_api_usage_once(self)
...@@ -874,6 +902,7 @@ class RandomResizedCrop(torch.nn.Module): ...@@ -874,6 +902,7 @@ class RandomResizedCrop(torch.nn.Module):
self.interpolation = interpolation self.interpolation = interpolation
self.antialias = antialias self.antialias = antialias
self.interpolation = interpolation
self.scale = scale self.scale = scale
self.ratio = ratio self.ratio = ratio
......
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