Syntax for a custom hue transform using torchvision.transforms

Hello :slight_smile:

I’m trying to do a hue transformation and the librairie doesn’t offer it so I looked at the PyTorch one and I can’t make it work, I do :

def _hue_tr(x):
return transforms.ColorJitter(brightness=0, contrast=0, saturation=0, hue=(0.1, 0.2))
hue_tr = TfmAffine(_hue_tr)

But I always get a UserWarning: There seems to be something wrong with your dataset, can’t access any element when using hue_tr() it in tfms.

Can someone figure out my mistake ?

Thanks !

I don’t think it’s going to be a TfmAffine since a TfmAffine requires you return a 3 by 3 matrix.
I think it’s probably more of a lighting transform, but you will have to dig in the implementation since pytorch applies transform on PIL images whereas we do it in fastai on tensors, so the pytorch function is likely to not work directly.

1 Like