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

Improve error message for RandomCrop #2809

Closed
vfdev-5 opened this issue Oct 14, 2020 · 0 comments · Fixed by #2816
Closed

Improve error message for RandomCrop #2809

vfdev-5 opened this issue Oct 14, 2020 · 0 comments · Fixed by #2816

Comments

@vfdev-5
Copy link
Collaborator

vfdev-5 commented Oct 14, 2020

🚀 Feature

In case if we apply RandomCrop(256) on images smaller than 256, current error message does not provide the information about size mismatch

import torchvision.transforms as T

t = T.RandomCrop(224)
t(torch.randint(0, 256, size=(3, 32, 32), dtype=torch.uint8))
> 
  File "/user/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 575, in forward
    i, j, h, w = self.get_params(img, self.size)
  File "/user/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 538, in get_params
    i = torch.randint(0, h - th + 1, size=(1, )).item()
RuntimeError: random_ expects 'from' to be less than 'to', but got from=0 >= to=-191

It would be nice to have a more user-friendly error message if h - th + 1 < 0 saying that we have a size mismatch.

cc @vfdev-5

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

Successfully merging a pull request may close this issue.

2 participants