I have a preprocessing pipeling with transforms.Compose()
. However, I’m wondering if this can also handle batches in the same way as nn.Sequential()
?
A minimal example, where the img_batch creation doesn’t work obviously…
import torch
from torchvision import transforms
from PIL import Image
img1 = Image.open('img1')
img2 = Image.open('img2')
img3 = Image.open('img3')
img_batch = torch.Tensor([img1, img2, img3])
preproc = transforms.Compose([
transforms.ToTensor()
])
preproc(img_batch)