gnp.dataset module
gnp.dataset.patch
- class gnp.dataset.patch.PatchGenerator(data: dict, graph_radius: float, batch_size: int = 1, center: str = 'tree', shuffle_patches: bool = True, knn: int = 50, min_radius: float = 0.01, pca: bool = True, degree: int = 3, orientation: Tensor | None = None, min_z_scale: float = 0.001, max_num_neighbors: int = 32, device: str = 'cpu')[source]
Bases:
object
PatchLoader class that generates patches from a point cloud.
- Parameters:
data (dict) -- Point cloud data. Must include keys 'x' for point cloud and 'normals' which must have the correct orientation of the pointcloud. The normals do not need to be accurate other than the orientation.
graph_radius (float) -- Radius for graph construction.
batch_size (int, optional) -- Batch size. Defaults to 1.
center (str, optional) -- Method for choosing patch centers. If 'tree', a KDTree is used to ensure patches completely cover the point cloud. If 'gmls', there is one patch for every point in the data. Defaults to 'tree'.
shuffle_patches (bool, optional) -- Whether to shuffle patches. Defaults to True.
knn (int, optional) -- Number of neighbors to choose for patch construction. Defaults to 50.
min_radius (float, optional) -- Minimum patch radius. Defaults to 0.01.
pca (bool, optional) -- If True, returns patch in local PCA coordinates. Defaults to True.
degree (int, optional) -- Maximum degree of 1D Legendre basis if pca is True. Defaults to 3.
orientation (Optional[torch.Tensor], optional) -- Orientation used if pca is True. Defaults to None.
scale (bool, optional) -- If True, scaling is used if pca is also True. Defaults to True.
include_scale (bool, optional) -- If True, includes scale in the output. Defaults to True.
min_z_scale (float, optional) -- Minimum scale used in pca rescaling. Defaults to 1e-3.
max_num_neighbors (int, optional) -- Maximum neighbors used in graph construction. Defaults to 32.
device (str, optional) -- Device to use. Defaults to 'cpu'.
- get_centers() LongTensor [source]
Choose the centers of the patches. If self.center is 'tree', the centers are chosen so that there is sufficient coverage of the data. If self.center is 'gmls', there is one patch center :returns: Indices of the patch centers. :rtype: torch.LongTensor
- class gnp.dataset.patch.PatchLoader(graph_radius: float, batch_size: int = 1, center: str = 'tree', shuffle_patches: bool = True, knn: int = 50, min_radius: float = 0.01, pca: bool = True, degree: int = 3, min_z_scale: float = 0.001, max_num_neighbors: int = 32, device: str = 'cpu')[source]
Bases:
object
PatchLoader class that outputs a PatchGenerator instance when given PCD data.
- Parameters
- graph_radiusfloat
Radius for graph construction.
- batch_sizeint, optional
Batch size. Defaults to 1.
- centerstr, optional
Method for choosing patch centers. If 'tree', a KDTree is used to ensure patches completely cover the point cloud. If 'gmls', there is one patch for every point in the data. Defaults to 'tree'.
- shuffle_patchesbool, optional
Whether to shuffle patches. Defaults to True.
- knnint, optional
Number of neighbors to choose for patch construction. Defaults to 50.
- min_radiusfloat, optional
Minimum patch radius. Defaults to 0.01.
- pcabool, optional
If True, returns patch in local PCA coordinates. Defaults to True.
- degreeint, optional
Maximum degree of 1D Legendre basis if pca is True. Defaults to 3.
- min_z_scalefloat, optional
Minimum scale used in pca rescaling. Defaults to 1e-3.
- max_num_neighborsint, optional
Maximum neighbors used in graph construction. Defaults to 32.
- devicestr, optional
Device to use. Defaults to 'cpu'.
- gnp.dataset.patch.graph_from_dict(sample: dict, radius: float, max_num_neighbors: int = 32)[source]
Construct a graph from a dictionary of node features and other data.
- Parameters:
sample (dict) -- Dictionary containing the node features and other data.
radius (float) -- Radius for the radius graph.
max_num_neighbors (int, optional) -- Maximum number of neighbors per node. Defaults to 32.
- Returns:
A graph data object containing node features, edge indices, and edge attributes.
- Return type:
torch_geometric.data.Data
gnp.dataset.pca
- class gnp.dataset.pca.PCABatch(num_graphs: int, **kwargs)[source]
Bases:
object
Class for handling multiple PCA patches.