Could you print the shape of the image before passing it to the transformation.
I’m not sure, if OpenCV creates pseudo-color channels if you are loading a grayscale image, but if not that could yield this error.
If that’s the case, you could extend your tensor in that dimension to create 3 identical color channels.