I would guess that the error is raised while trying to stack the target images as you are only resizing the input images.
Use target_transform to transform the target images too or use transforms and pass transformations to the dataset, which accept an image and target.