I can’t reproduce this issue, and this code works fine on my machine:
def lbp_transform(x):
    radius = 2
    n_points = 8 * radius
    METHOD = 'uniform'
    imgUMat = np.float32(x)
    gray = cv2.cvtColor(imgUMat, cv2.COLOR_RGB2GRAY)
    lbp = local_binary_pattern(gray, n_points, radius, METHOD)
    lbp = torch.from_numpy(lbp).float()
    return lbp


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

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])

Could you compare your code to my code snippet?