RuntimeError: Given groups=1, weight of size 64 6 1, expected input[16, 9, 4096] to have 6 channels, but got 9 channels instead
该个错误主要是因为S3DIS数据集的数据具有9个通道,涉及xyz、rgb和归一化XYZ。但是代码仅支持 3 或 6 个通道。要解决此问题,应进行一些小的修改。
1 pointnet_sem_seg.py;通过添加 if来考虑通道 =9 的情况。with_normalized_xyz params
class get_model(nn.Module):
def __init__(self, num_class, with_rgb=True, with_normalized_xyz=True):
super(get_model, self).__init__()
if with_rgb:
channel = 6
if with_normalized_xyz:
channel= 9
else:
...
2 pointnet.py;更改 PointNetEncoder 的前向方法,稍微修改拆分方法
def forward(self, x):
B, D, N = x.size() # batchsize,3(xyz坐标)或6(xyz坐标+法向量),1024(一个物体所取的点的数目)
trans = self.stn(x) # STN3d T-Net
x = x.transpose(2, 1) # 交换一个tensor的两个维度
if D >3 :
# x, feature = x.split(3,dim=2)
x, feature = x.split([3,D-3],dim=2)
3 这样就可以解决S3DIS数据集在pointnet++训练时的场景分割报错了。