Skip to content

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

@hyperkai

Description

@hyperkai

🚀 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

Metadata

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