How to add a batch dimension in my picture?

when i use model witch i have trainde to predict .i just could conver the picture to tensor with the shape of CWH.But my data missing a batch dimension.So how to add the batch dimension when prediction.?Thank you very much.

Assume your image being in tensor x you could do x.unsqueeze(0) or you could use the pytorch data package and it’s Datasets/Dataloader which automatically create minibatches.
For vision there is something similar in the torchvision package.

1 Like