Conversation
|
ColorJitter from PyTorch includes support for both grayscale and RGB images, is it possible you could add this feature before we merge it in? |
|
I would love to ! However it's not obvious how to check the number of channel in the compiled function. I tried several things but still got the following errors when trying to check the shape: No implementation of function Function(<function runtime_broadcast_assert_shapes at 0x7f6657fbc670>). I am not super familiar with Numba but ideally, we should compiled one function for RGB and another one for Grayscale, but we will not have the shape until the call to the compiled function. |
Hi everyone, I just wanted to share my implementation of ColorJitter which is very close to the one used in torchvision.
As ColorJitter in torchvision.transforms, you can specify a float, or a (min,max) to sample the different ratio for brightness/contrast/saturation and hue.
I did simple tests to visualize the transformations between the Pytorch and FFCV version:


ColorJitter (only hue) from torchvision.transforms:
ColorJitter (only hue) from this pull request (FFCV):
And ColorJitter with different values for brightness/contrast/saturation and hue:

The code used for brightness/contrast/saturation is identical to the ones used in torchvision.transforms, however concerning hue, the code used is an adaptation from
https://sanje2v.wordpress.com/2021/01/11/accelerating-data-transforms/
https://stackoverflow.com/questions/8507885