The code seems to work correctly.
This code snippet applies the transformation only:
def lbp_transform(x):
    imgUMat = np.float32(x)
    lbp = imgUMat * 10 # fake transformation
    lbp = torch.from_numpy(lbp)
    return lbp

x = np.random.randn(600, 600)
out = lbp_transform(x)
print(out.shape)
> torch.Size([600, 600])

while this snippet wraps it in a torchvision.transforms.Compose object:
tfms = transforms.Compose([
    transforms.Lambda(lbp_transform),
    transforms.ToPILImage(),
    transforms.Resize((300, 300)),
    transforms.ToTensor()
])

out = tfms(x)
print(out.shape)
> torch.Size([1, 300, 300])

Are you sure this indexing is correct and you are not in fact indexing into the height dimension?
(train_ds[0][0][0]).shape