vision icon indicating copy to clipboard operation
vision copied to clipboard

`sigma` argument of `ElasticTransform()` should completely avoid negative values, giving error and the doc should have the explanation.

Open hyperkai opened this issue 11 months ago • 1 comments

📚 The doc issue

sigma argument of ElasticTransform() doesn't like negative values as I show in this issue.

And, setting 0 and -100 to sigma argument of ElasticTransform() gets the same results as shown below:

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

my_data = OxfordIIITPet(
    root="data"
)

import matplotlib.pyplot as plt

def show_images(data, main_title=None, a=50, s=5, f=0):
    plt.figure(figsize=(10, 5))
    plt.suptitle(t=main_title, y=0.8, fontsize=14)
    for i, (im, _) in zip(range(1, 6), data):
        plt.subplot(1, 5, i)
        et = ElasticTransform(alpha=a, sigma=s, fill=f) # Here
        plt.imshow(X=et(im)) # Here
        plt.xticks(ticks=[])
        plt.yticks(ticks=[])
    plt.tight_layout()
    plt.show()

show_images(data=my_data, main_title="sigma0_data", s=0) # Here
show_images(data=my_data, main_title="sigma-100", s=-100) # Here

Image

Image

Suggest a potential alternative/fix

So, sigma argument should completely avoid negative values, giving error and the doc should have the explanation.

hyperkai avatar Jan 24 '25 02:01 hyperkai

Happy to consider a PR for the docs. Not sure we need to raise at this point, considering there might be existing usage which we would be breaking

NicolasHug avatar Feb 19 '25 13:02 NicolasHug