Problems creating custom transforms

Trying to create custom transforms in Fastai, I have encountered serious difficulties. My transforms are meant to change pixel values, not their position I.e solarize, posterize, etc. I used PIL.ImageOps and torch.transforms and I wrapped the basic function in tfmLighting. The results were nonsensical. Tracking the code within Fastai, I found that tfmLighting modifies the original Image tensor by applying the Logit function; therefore, all calculations involving PIL and torch transforms give incorrect results. I have the following questions:

  1. What is the rationale for modifying the original image tensor with Logit in tfmLighting and yet leaving the tensor unmodified when wrapped in tfmPixel?
  2. Would mixing modified and unmodified tensors introduce instability during training?
  3. Can I wrap my pixel-changing transforms in tfmPixel instead of tfmLightning. If I can’t, the only solution to the problem is to apply Inverse Logit at the beginning of the transform and then apply Logit at the end.

TfmLighting is a fastai class we use because we change contrast and lighting on the logits directly. If you want to change the pixel values, you need to use TfmPixel.