Skip to content

Setting 5.3 and 9 to bits argument of RandomPosterize() gets an indirect error message #8910

@hyperkai

Description

@hyperkai

🐛 Describe the bug

Setting 5.3 and 9 to bits argument of RandomPosterize() gets the indirect error message as shown below:

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

my_data1 = OxfordIIITPet(
    root="data",                 # ↓↓↓
    transform=RandomPosterize(bits=5.3)
)

my_data2 = OxfordIIITPet(
    root="data",                 # ↓
    transform=RandomPosterize(bits=9)
)

my_data1[0] # Error
my_data2[0] # Error

TypeError: bad operand type for unary ~: 'float'

TypeError: bad operand type for unary ~: 'float'

So, they should be something direct like below respectively:

TypeError: bits must be int

ValueError: bits must be [0, 8]

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