Skip to content

Setting a list of float type values to padding argument of RandomCrop() gets the indirect error message #8891

Open
@hyperkai

Description

🐛 Describe the bug

Setting a list of float type values to padding argument of RandomCrop() gets the indirect error message as shown below:

from torchvision.datasets import OxfordIIITPet
from torchvision.transforms.v2 import RandomCrop

my_data = OxfordIIITPet(
    root="data",                                # ↓↓↓↓↓↓↓↓↓↓↓↓
    transform=RandomCrop(size=[100, 200], padding=[10.8, 20.3])
)

my_data[0][0] # Error
TypeError: randint() received an invalid combination of arguments - got (int, float, size=tuple), but expected one of:
 * (int high, tuple of ints size, *, torch.Generator generator, Tensor out = None, torch.dtype dtype = None, torch.layout layout = None, torch.device device = None, bool pin_memory = False, bool requires_grad = False)
 * (int high, tuple of ints size, *, Tensor out = None, torch.dtype dtype = None, torch.layout layout = None, torch.device device = None, bool pin_memory = False, bool requires_grad = False)
 * (int low, int high, tuple of ints size, *, torch.Generator generator, Tensor out = None, torch.dtype dtype = None, torch.layout layout = None, torch.device device = None, bool pin_memory = False, bool requires_grad = False)
 * (int low, int high, tuple of ints size, *, Tensor out = None, torch.dtype dtype = None, torch.layout layout = None, torch.device device = None, bool pin_memory = False, bool requires_grad = False)

So, the error message should be something direct like below:

TypeError: padding should be an integer or tuple or list of integers, but got 10.8

Versions

import torchvision

torchvision.__version__ # '0.20.1'

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions