Skip to content

ColorJitter doesn't check bounds for single value inputs #7132

@pmeier

Description

@pmeier

The parameters passed to ColorJitter can be passed either as single number or as a two-tuple. Doing the former internally creates a two tuple as well using the passed value as offset from a hardcoded center. For example, the center for hue is 0 and so we have

from torchvision.prototype import transforms

transform1 = transforms.ColorJitter(hue=0.3)
transform2 = transforms.ColorJitter(hue=(-0.3, 0.3))

assert transform1.hue == transform2.hue

However, when it comes to check for out of bounds values, passing a single value goes unchecked, while passing the corresponding two-tuple fails

transform1 = transforms.ColorJitter(hue=1.0)

assert transform1.hue == (-1.0, 1.0)

transforms.ColorJitter(hue=(-1.0, 1.0))
ValueError: hue values should be between (-0.5, 0.5)

We should apply the same check to the single value as well.

cc @vfdev-5

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions