From 1476b2075464b21839ac56708cd834879a44b602 Mon Sep 17 00:00:00 2001 From: Philip Meier Date: Wed, 16 Mar 2022 15:20:50 +0100 Subject: [PATCH] remove option to pass fill as str --- torchvision/transforms/functional.py | 4 ++-- torchvision/transforms/functional_pil.py | 2 +- torchvision/transforms/transforms.py | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/torchvision/transforms/functional.py b/torchvision/transforms/functional.py index 7234d923fbc..547e67d484d 100644 --- a/torchvision/transforms/functional.py +++ b/torchvision/transforms/functional.py @@ -448,11 +448,11 @@ def pad(img: Tensor, padding: List[int], fill: int = 0, padding_mode: str = "con .. note:: In torchscript mode padding as single int is not supported, use a sequence of length 1: ``[padding, ]``. - fill (number or str or tuple): Pixel fill value for constant fill. Default is 0. + fill (number or tuple): Pixel fill value for constant fill. Default is 0. If a tuple of length 3, it is used to fill R, G, B channels respectively. This value is only used when the padding_mode is constant. Only number is supported for torch Tensor. - Only int or str or tuple value is supported for PIL Image. + Only int or tuple value is supported for PIL Image. padding_mode (str): Type of padding. Should be: constant, edge, reflect or symmetric. Default is constant. diff --git a/torchvision/transforms/functional_pil.py b/torchvision/transforms/functional_pil.py index ba0159a1123..5362ebd593c 100644 --- a/torchvision/transforms/functional_pil.py +++ b/torchvision/transforms/functional_pil.py @@ -154,7 +154,7 @@ def pad( if not isinstance(padding, (numbers.Number, tuple, list)): raise TypeError("Got inappropriate padding arg") - if not isinstance(fill, (numbers.Number, str, tuple, list)): + if not isinstance(fill, (numbers.Number, tuple, list)): raise TypeError("Got inappropriate fill arg") if not isinstance(padding_mode, str): raise TypeError("Got inappropriate padding_mode arg") diff --git a/torchvision/transforms/transforms.py b/torchvision/transforms/transforms.py index a5081390f2d..d18e20e1342 100644 --- a/torchvision/transforms/transforms.py +++ b/torchvision/transforms/transforms.py @@ -400,11 +400,11 @@ class Pad(torch.nn.Module): .. note:: In torchscript mode padding as single int is not supported, use a sequence of length 1: ``[padding, ]``. - fill (number or str or tuple): Pixel fill value for constant fill. Default is 0. If a tuple of + fill (number or tuple): Pixel fill value for constant fill. Default is 0. If a tuple of length 3, it is used to fill R, G, B channels respectively. This value is only used when the padding_mode is constant. Only number is supported for torch Tensor. - Only int or str or tuple value is supported for PIL Image. + Only int or tuple value is supported for PIL Image. padding_mode (str): Type of padding. Should be: constant, edge, reflect or symmetric. Default is constant. @@ -428,7 +428,7 @@ def __init__(self, padding, fill=0, padding_mode="constant"): if not isinstance(padding, (numbers.Number, tuple, list)): raise TypeError("Got inappropriate padding arg") - if not isinstance(fill, (numbers.Number, str, tuple, list)): + if not isinstance(fill, (numbers.Number, tuple, list)): raise TypeError("Got inappropriate fill arg") if padding_mode not in ["constant", "edge", "reflect", "symmetric"]: @@ -595,11 +595,11 @@ class RandomCrop(torch.nn.Module): pad_if_needed (boolean): It will pad the image if smaller than the desired size to avoid raising an exception. Since cropping is done after padding, the padding seems to be done at a random offset. - fill (number or str or tuple): Pixel fill value for constant fill. Default is 0. If a tuple of + fill (number or tuple): Pixel fill value for constant fill. Default is 0. If a tuple of length 3, it is used to fill R, G, B channels respectively. This value is only used when the padding_mode is constant. Only number is supported for torch Tensor. - Only int or str or tuple value is supported for PIL Image. + Only int or tuple value is supported for PIL Image. padding_mode (str): Type of padding. Should be: constant, edge, reflect or symmetric. Default is constant.