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

·····运行eriklindernoren/PyTorch-YOLOv3,出现错误RuntimeError: Given groups=1, weight of size 32 3 3 3, expected input[1, 4, 416, 416] to have 3 channels, but got 4 channels instead

·····解决方法:
·····把img = transforms.ToTensor()(Image.open(img_path))
改为:
img = transforms.ToTensor()(Image.open(img_path).convert(‘RGB’))

你可能感兴趣的:(RuntimeError: Given groups=1, weight of size 32 3 3 3, expected input[1, 4, 416, 416] to have 3 chan)