Pytorch dataloader transforms not working

Below is my dataloaders and transforms
coco_train = = coco(root_dir=“./data/COCO”, image_set=“train”, year=2017, transforms=get_transform(train=True))
coco_val = = coco(root_dir=“./data/COCO”, image_set=“val”, year=2017, transforms=get_transform(train=False))

define training and validation data loaders

data_loader =
coco_train, batch_size=BATCH_SIZE, shuffle=True, num_workers=4, collate_fn=coco_train.collate_fn)
data_loader_no_random =
coco_val, batch_size=BATCH_SIZE, shuffle=False, num_workers=4,collate_fn=coco_val.collate_fn)

def get_transform(train):
transforms = []
# converts the image, a PIL image, into a PyTorch Tensor

if train:
    # during training, randomly flip the training images
    # and ground-truth for data augmentation
return T.Compose(transforms)

When I iterate over data_loader like this
for image,target in data_loader:
bla bla
image is of datatype PIL.Image still even though transforms are applied in the custom dataset class coco.
I appreciate any suggestions and work around this.

Check how the __getitem__ of your custom Dataset is defined and where the transformation is supposed to be used.