Skip to content

Setting a list of no transforms to transforms argument of RandomApply() gets the indirect error message #9022

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

Open
hyperkai opened this issue Apr 18, 2025 · 1 comment

Comments

@hyperkai
Copy link

hyperkai commented Apr 18, 2025

📚 The doc issue

Setting a list of no transforms to transforms argument of RandomApply() gets the indirect error message as shown below. *You can see this issue as well:

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

my_data = OxfordIIITPet(
    root="data",                   # ↓↓
    transform=RandomApply(transforms=[], p=1)
)

my_data[0][0] # Error

UnboundLocalError: cannot access local variable 'outputs' where it is not associated with a value

So, it should be something direct like below:

ValueError: There must be at least one transform

Suggest a potential alternative/fix

import torchvision

torchvision.__version__ # '0.20.1'
@NicolasHug
Copy link
Member

Thanks for the report, feel free to submit a PR @hyperkai

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