问题描述

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

原因

维度信息不匹配。

解决办法

image = Image.open(image_path)

改为

image = Image.open(image_path).convert('RGB')