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

Setting the 1D list of 1 element to RandomRotation() and RandomAffine() works against an error message #8863

Open
hyperkai opened this issue Jan 16, 2025 · 0 comments

Comments

@hyperkai
Copy link

🐛 Describe the bug

Setting the 1D list of 2 elements to RandomRotation() and RandomAffine() got the error message as shown below:

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

my_data = OxfordIIITPet(
    root="data",
    transform=RandomRotation(degrees=[0.0, 0.0],
                             fill=[50.0, 50.0])
)

my_data[0] # Error

my_data = OxfordIIITPet(
    root="data",
    transform=RandomAffine(degrees=[0.0, 0.0],
                           fill=[50.0, 50.0])
)

my_data[0] # Error

ValueError: The number of elements in 'fill' does not match the number of channels of the image (2 != 3)

But setting the 1D list of 1 element to RandomRotation() and RandomAffine() works against the above error message as shown below:

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

my_data = OxfordIIITPet(
    root="data",
    transform=RandomRotation(degrees=[0.0, 0.0],
                             fill=[50.0])
)

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

my_data = OxfordIIITPet(
    root="data",
    transform=RandomAffine(degrees=[0.0, 0.0],
                           fill=[50.0])
)

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

Versions

import torchvision

torchvision.__version__ # '0.20.1'
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

1 participant