How to include transforms.functional.equalize in a compose code block

Hi All,

I have a code block which I took from here. I am trying to customise it and want to include transforms.functional.equalize in the compose section as below:

# Data augmentation and normalization for training
# Just normalization for validation
data_transforms = {
    'train': transforms.Compose([
        transforms.RandomResizedCrop(224,scale=(0.85, 0.95)),
        transforms.functional.equalize() #Not sure how to include it here
        transforms.RandomAdjustSharpness(1.2),
        transforms.RandomHorizontalFlip(),
        transforms.ToTensor(),
        transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
    ]),
    'val': transforms.Compose([
        transforms.Resize(256),
        transforms.CenterCrop(224),
        transforms.ToTensor(),
        transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
    ]),
}

Would anyone be able help me to include the transforms.functional.equalize function in the compose pipline.

Thanks & Best Regards
Michael

You can create a new transformation module and add it to the Compose object. Take a look at e.g. ToTensor to see how the object is implemented and how the functional API is used.

1 Like