jupyter notebook报错:RunTimeError

jupyter notebook报错:RunTimeError:The size of tensor a (4) must match the size of tensor b (3) at non-singleton dimension 0

解决方法:

imag_as_pil = Image.open(image_path)
改为
imag_as_pil = Image.open(image_path).convert(‘RGB’)
即可。

出现这个问题得原因可能是有的图片是四通道的。

参考:https://blog.csdn.net/dongfang1984/article/details/103110893

你可能感兴趣的:(人工智能,python)