Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For degrees argument of RandomRotation(), [90.0, 90.0] should rotate clockwise and [-90.0, -90.0]) should rotate anticlockwise #8828

Open
hyperkai opened this issue Dec 24, 2024 · 1 comment

Comments

@hyperkai
Copy link

🚀 The feature

Setting [90.0, 90.0] and [-90.0, -90.0]) to degrees argument of RandomRotation() rotates 90 degrees anticlockwise and clockwise respectively as shown below but it's not intuitive that [90.0, 90.0] rotates anticlockwise and [-90.0, -90.0]) rotates clockwise:

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

origin_data = OxfordIIITPet(
    root="data",
    transform=None
)

p90p90_data = OxfordIIITPet( # `p` is plus.
    root="data",
    transform=RandomRotation(degrees=[90.0, 90.0])
)

m90m90_data = OxfordIIITPet( # `m` is minus.
    root="data",
    transform=RandomRotation(degrees=[-90.0, -90.0])
)

import matplotlib.pyplot as plt

def show_images(data, main_title=None):
    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)
        plt.imshow(X=im)
        plt.xticks(ticks=[])
        plt.yticks(ticks=[])
    plt.tight_layout()
    plt.show()

show_images(data=origin_data, main_title="origin_data")
show_images(data=p90p90_data, main_title="p90p90_data")
show_images(data=m90m90_data, main_title="m90m90_data")

Screenshot 2024-12-24 153036
Screenshot 2024-12-24 153110
Screenshot 2024-12-24 153225

Motivation, pitch

So, [90.0, 90.0] should rotate clockwise and [-90.0, -90.0]) should rotate anticlockwise.

Alternatives

No response

Additional context

No response

@abhi-glitchhg
Copy link
Contributor

abhi-glitchhg commented Dec 25, 2024

Great point , we should update the docs with this behaviour if this is counter intuitive.

Generally anticlockwise is positive only, so we are correct with the general convention. But mentioning this in doc would be helpful for general public.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants