pyg-team / pytorch_geometric

Graph Neural Network Library for PyTorch
https://pyg.org
MIT License
21.49k stars 3.69k forks source link

pointnet2_segmentation.py question regarding shapenet.py -- shapenet.py's "include_normals" flag is not followed in process_filenames() #3245

Open MBrandt-NASA opened 3 years ago

MBrandt-NASA commented 3 years ago

Discussed in https://github.com/pyg-team/pytorch_geometric/discussions/3243

Originally posted by **MBrandt-NASA** September 26, 2021 Hi, Thanks for creating the amazing PyG :). In shapenet.py you have the comment: include_normals (bool, optional): If set to :obj:`False`, will not include normal vectors as input features. (default: :obj:`True`) And indeed in __init__() you have: `self.data.x = self.data.x if include_normals else None` That's great (I don't have normals for my data ;), but then later in process_filenames() you have: `pos = data[:, :3]` `x = data[:, 3:6]` `y = data[:, -1].type(torch.long)` `data = Data(pos=pos, x=x, y=y, category=cat_idx[cat])` So the normals are getting read into "x" from the ShapeNet data files even tho' "include_normals" above was set to False. I had assumed that I could just run pointnet2_segmentation.py with "x = None". But then in a module like SAModule you have: def forward(self, x, pos, batch): idx = fps(pos, batch, ratio=self.ratio) row, col = radius(pos, pos[idx], self.r, batch, batch[idx], max_num_neighbors=64) edge_index = torch.stack([col, row], dim=0) x = self.conv(x, (pos, pos[idx]), edge_index) pos, batch = pos[idx], batch[idx] return x, pos, batch So that obviously references "x" a lot... Does pointnet2_segmentation.py support not having any normals in the input data? Or should I try running with x=pos to duplicate pos, or something like that? Thanks :)

Note that: the include_normals flag isn't obeyed in shapenet.py's process_filenames()... needs fixing ;)

Solution for those who don't want to use normals in pointnet2_segmentation.py, at least, I think this works, so far ;) --

So I found this issue, which showed when support was added for normals in shapenet:

884

Then checking the history of pointnet2_segmentation.py, I noticed this update made to support normals: d782f8b#diff-5134187ae97d9080b798f14053558d38d996a6ba8177454dcfccfbf05a0955b7 which contained: self.sa1_module = SAModule(0.2, 0.2, MLP([3 + 3, 64, 64, 128]))

And later this one: a4f51d3#diff-5134187ae97d9080b798f14053558d38d996a6ba8177454dcfccfbf05a0955b7

which had: self.fp1_module = FPModule(3, MLP([128 + 3, 128, 128, 128]))

So I removed the 2 "+ 3"'s that were added, and I seem to be able to run without normals... in case anyone else runs into this.

rusty1s commented 3 years ago

Please see my answer here https://github.com/pyg-team/pytorch_geometric/discussions/3243#discussioncomment-1389633.