pytorch / pytorch/vision

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

Open
#8,877 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
17.9k
Forks
7.3k
Avg merge
1d 15h
Merged PRs (30d)
13

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'

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up β€” it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the ElasticTransform() entry point and reproduce the reported behavior with sigma=-100 and sigma=[-100, -100], then compare it with the mixed-sign examples. Check the existing validation and its error message. Done means all negative sigma values are rejected consistently with the documented error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-vision
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.