这种本来应该是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')
解决