How do the transforms actually work in PyTorch?

torchvision.transforms.v2.RandomEqualize(p: float = 0.5)

If I increase the probability to 1 here, does that mean it equalizes all the images and the original images are never seen in the network?

Is there any way to see how many images are actually being shown to the network. Like a dry run to see the number of images passing with and without augmentation?

A random number is generated from U(0, 1). The function initialized a probability threshold. If the value is larger thsn the threshold the whole batch is histogram equalized, image per image.

Thank you for the answer! Clears my doubt.

So essentially then, if the probability is set as 1, it acts as a pre-processing step rather than an augmentation? Am I right in saying this?

Ya I think you could write something like

transform = torchvision.transforms.v2.RandomEqualize(p=1.0)
ims = transform(ims) # ims a tensor of shape [N, 3, H, W] or [N, 1, H, W]

where N is the batch size, 3 or 1 is the number of channels, H is the image height, W is the image width, and this would histogram equalize the batch.

Alternatively if you wanted to randomly histogram equalize within the batch, I think you could do something like

for i in range(ims.shape[0]):
    if random.rand() > 0.5:
         ims[i] = transform(torch.unsqueeze(ims[i], dim=0))[0]