Taget and input must have the same number of elements

Yes, if you are resizing your input images, you should also resize the masks, too.
However, make sure to use interpolation=PIL.Image.NEAREST, otherwise your class indices might be distorted.
Also, if you are planning on applying random data transformations, I would recommend to use the functional API as described in this post to make sure both the image and mask are using the same random values.

1 Like