Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hyperkai opened this issue Jan 30, 2025 · 0 comments

Comments

@hyperkai
Copy link

🐛 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'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant