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')

 

解决

你可能感兴趣的:(#,Deep,Learning,#,Code,debug)