Source code for torch_geometric.io.ply
import torch
from plyfile import PlyData
from torch_geometric.data import Data
[docs]def read_ply(path):
with open(path, 'rb') as f:
data = PlyData.read(f)
pos = ([torch.tensor(data['vertex'][axis]) for axis in ['x', 'y', 'z']])
pos = torch.stack(pos, dim=-1)
face = None
if 'face' in data:
faces = data['face']['vertex_indices']
faces = [torch.tensor(fa, dtype=torch.long) for fa in faces]
face = torch.stack(faces, dim=-1)
data = Data(pos=pos, face=face)
return data