I faced the same problem and alex has explained it properly.
Use this, to convert a [H,W,C] into [C,H,W]
For including batch_size(N) use DataLoader, it will automatically include
image = image.transpose((2, 0, 1))