Pytorch RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton dimension 0

I suspect your test_image has an additional alpha channel per pixel, thus it has 4 channels instead of only three.
Try:

test_image = Image.open(test_image_name).convert('RGB')

Leave a Comment