Skip to content

Setting float and bool values to quality argument of JPEG() gets the indirect errors #8917

@hyperkai

Description

@hyperkai

🐛 Describe the bug

Setting float and bool values to quality argument of JPEG() gets the indirect errors as shown below:

from torchvision.transforms.v2 import JPEG

JPEG(quality=5.3) # Error

TypeError: quality should be a sequence of length 2.

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

my_data = OxfordIIITPet(
    root="data",
    transform=JPEG(quality=True)
)

my_data[0] # Error
TypeError: randint() received an invalid combination of arguments - got (bool, int, 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 they should be something direct like below:

TypeError: quality argument must be int

Versions

import torchvision

torchvision.__version__ # '0.20.1'

Metadata

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