Skip to content

Setting a single negative value or a couple of negative values to sigma argument of ElasticTransform() doesn't get error against the error message #8877

Open
@hyperkai

Description

🐛 Describe the bug

Setting a negative and positive value together to sigma argument of ElasticTransform() gets the error messages as shown below:

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

my_data1 = OxfordIIITPet(
    root="data",             # ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
    transform=ElasticTransform(sigma=[-100, 100])
)

my_data2 = OxfordIIITPet(
    root="data",             # ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
    transform=ElasticTransform(sigma=[100, -100])
)

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

ValueError: sigma should have positive values. Got [-100.0, 100.0]

ValueError: sigma should have positive values. Got [100.0, -100.0]

But setting a single negative value or a couple of negative values to sigma argument of ElasticTransform() doesn't get error against the above error message as shown below:

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

my_data1 = OxfordIIITPet(
    root="data",             # ↓ ↓ ↓ ↓ ↓
    transform=ElasticTransform(sigma=-100)
)

my_data2 = OxfordIIITPet(
    root="data",             # ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
    transform=ElasticTransform(sigma=[-100, -100])
)

my_data1[0]
# (<PIL.Image.Image image mode=RGB size=394x500>, 0)

my_data2[0]
# (<PIL.Image.Image image mode=RGB size=394x500>, 0)

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