You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<ipython-input-3-9196a1451978>in<lambda>(x)
26 ])
27rotation=rotations[c]
--->28data_description.transforms.append(lambdax: (rotation(x[0]), x[1]))
29returntask_description/usr/local/lib/python3.7/dist-packages/torchvision/transforms/transforms.pyin__call__(self, img)
58def__call__(self, img):
59fortinself.transforms:
--->60img=t(img)
61returnimg62/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.pyin_call_impl(self, *input, **kwargs)
1049ifnot (self._backward_hooksorself._forward_hooksorself._forward_pre_hooksor_global_backward_hooks1050or_global_forward_hooksor_global_forward_pre_hooks):
->1051returnforward_call(*input, **kwargs)
1052# Do not call functions when jit is used1053full_backward_hooks, non_full_backward_hooks= [], []
/usr/local/lib/python3.7/dist-packages/torchvision/transforms/transforms.pyinforward(self, img)
1284angle=self.get_params(self.degrees)
1285->1286returnF.rotate(img, angle, self.resample, self.expand, self.center, fill)
12871288def__repr__(self):
/usr/local/lib/python3.7/dist-packages/torchvision/transforms/functional.pyinrotate(img, angle, interpolation, expand, center, fill, resample)
988ifnotisinstance(img, torch.Tensor):
989pil_interpolation=pil_modes_mapping[interpolation]
-->990returnF_pil.rotate(img, angle=angle, interpolation=pil_interpolation, expand=expand, center=center, fill=fill)
991992center_f= [0.0, 0.0]
/usr/local/lib/python3.7/dist-packages/torchvision/transforms/functional_pil.pyinrotate(img, angle, interpolation, expand, center, fill)
276raiseTypeError("img should be PIL Image. Got {}".format(type(img)))
277-->278opts=_parse_fill(fill, img)
279returnimg.rotate(angle, interpolation, expand, center, **opts)
280/usr/local/lib/python3.7/dist-packages/torchvision/transforms/functional_pil.pyin_parse_fill(fill, img, name)
254msg= ("The number of elements in 'fill' does not match the number of "255"bands of the image ({} != {})")
-->256raiseValueError(msg.format(len(fill), num_bands))
257258fill=tuple(fill)
ValueError: Thenumberofelementsin'fill'doesnotmatchthenumberofbandsoftheimage (1!=3)
This implementation of RandomClassRotation was originally meant for Omniglot, which only has 1 channel (Aircrafts has 3, hence the error). Your modifications are worth a shot and I'd be happy to merge them if they fix the issue.
Also, if the user runs a recent enough version of torchvision, we could by-pass the back-and-forth between PILImage and Tensors since the newer transforms work directly on Tensors.
Thanks @seba-1511 . I will raise a PR that incorporates these changes this weekend. Bypassing makes sense. I can also try making use of only torchvision instead of PIL. In that case, do you want to keep both in case users don't have a higher version of torchvision?
Hi @seba-1511, I was trying to generate a taskset for the
FGVC Aircraft
dataset usingRandomClassRotation
. Here's the minimum reproducible codeThis results in the following stacktrace:
As the error mentions, there's something with the
fill
inRandomClassRotation
class transform https://github.com/learnables/learn2learn/blob/master/learn2learn/vision/transforms.py#L14.instead of this:
Thanks, and do correct me if I am wrong.
The text was updated successfully, but these errors were encountered: