1.数据准备
数据采用
shapenetcore_partanno_segmentation_benchmark_v0
讯享网
数据下载地址:
https://shapenet.cs.stanford.edu/ericyi/shapenetcore_partanno_segmentation_benchmark_v0.zip
代码下载地址:GitHub - fxia22/kdnet.pytorch: implementation "Escape from Cells: Deep Kd-Networks for The Recognition of 3D Point Cloud Models" in pytorch
2.代码主题解读
讯享网cutdim, tree = make_cKDTree(point_set.numpy(), depth=levels)
将点云建立KDtree,返回Kd树结构,
cutdim_v = [(torch.from_numpy(np.array(item).astype(np.int64))) for item in cutdim] points = torch.FloatTensor(tree[-1]) points_v = Variable(torch.unsqueeze(torch.squeeze(points), 0)).transpose(2, 1).cuda()
数据转为tensor,并对points进行转置,准备送入网络
讯享网3.网络主要内容解读 x = F.relu(conv(x))self.conv1 = nn.Conv1d(3, 8 * 3, 1, 1)
数据变化:1*3*2048--->1*24*2048
x = x.view(-1, featdim, 3, dim)# 数据变化:1*24*2048--->1*8*3*2048
目的是将 数据转为 xyz*2048的格式,
讯享网x = x.view(-1, featdim, 3 * dim)1*8*3*2048--->1*8*(6144=2048*3)
将2048个点 变为 :xyz,xyz,xyz.....xyz的格式
sel = Variable(sel + (torch.arange(0, dim) * 3).long())
讯享网x = torch.index_select(x, dim=2, index=sel)#根据KD-Tree每个节点切割空间的维度 选出对应XYZ中的数据,此时数据格式为:1*8*2048
根据KDtree在xyz中的哪个维度进行的分割? 将对应的数据提取出来
x = x.view(-1, featdim, int(dim / 2), 2) # 将数据调整为,KD-Tree的最底部的2个叶节点
数据变为1*8*1024*2 为什么要这样分割? 每个树最末端都有2个叶子。
讯享网x = torch.squeeze(torch.max(x, dim=-1, keepdim=True)[0], 3)
选取最大的那个叶子 最后将数据变为1*8*1024

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/120150.html