-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Closed
Description
🚀 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
fmassa