Your code looks good and I’m wondering what size mismatch might occur.
The error message states that the dimension 2 has different sizes, which would be the height of the image tensors.
Since you are resizing them to 500 I’m not sure, what’s causing this issue.
Could you a few images somewhere so that we could debug it?