RuntimeError: Given groups=1, weight of size [64, 3, , ], expected input[1, 4, , ] to have 3

这种本来应该是3通道结果是4通道导致报错的问题一般是因为Image.open函数。

参考链接:https://www.computationalimaging.cn/2020/01/runtimeerror-given-groups1-weight-of.html

错误语句:

img = Image.open(osp.join(dspth, image_path))

此时读入图片即为4通道,故会报错。

正确语句:

img = Image.open(osp.join(dspth, image_path)).convert('RGB')

解决

发布了47 篇原创文章 · 获赞 11 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qazwsxrx/article/details/103755834