gnp package
Subpackages
- gnp.dataset module
- gnp.geometry module
- gnp.geometry.surface
SurfacePatch
SurfacePatch.det_metric
SurfacePatch.gaussian_curvature
SurfacePatch.inverse_metric
SurfacePatch.inverse_metric_derivatives
SurfacePatch.laplace_beltrami_first_terms
SurfacePatch.laplace_beltrami_from_coefficients()
SurfacePatch.laplace_beltrami_legendre_basis
SurfacePatch.laplace_beltrami_second_terms
SurfacePatch.local_coordinate_basis
SurfacePatch.mean_curvature
SurfacePatch.metric
SurfacePatch.normals
SurfacePatch.normals_pca
SurfacePatch.pca_coordinates
SurfacePatch.shape
SurfacePatch.tangents
SurfacePatch.tangents_pca
SurfacePatch.weingarten
SurfacePatch.xyz_coordinates
- gnp.geometry.legendre
- Module contents
- gnp.geometry.surface
- gnp.models module
Submodules
gnp.config module
- gnp.config.load_config(path: Path) dict [source]
Load a configuration file from a yaml file.
- Parameters:
path (str) -- Path to the yaml file.
- Returns:
Dictionary containing the configuration parameters.
- Return type:
dict
- gnp.config.load_model(model_path: Path) PatchGNP [source]
Load a model from a directory.
- Parameters:
model_dir (Path) -- Path to the model directory.
- Returns:
The loaded model.
- Return type:
torch.nn.Module
- gnp.config.load_patchloader(cfg: dict, **kwargs) PatchLoader [source]
Load a PatchLoader using a yaml file in data_dir.
- Parameters:
cfg (dict) -- Dictionary containing the configuration parameters.
gnp.estimator module
- class gnp.estimator.GeometryEstimator(pcd: Tensor, orientation: Tensor, function_values: Tensor | None = None, model: str = 'clean_30k', device: device = 'cpu', **patch_kwargs: dict | None)[source]
Bases:
object
Geometry estimator for a point cloud.
- Parameters:
pcd (torch.Tensor) -- Point cloud data.
orientation (torch.Tensor) -- Orientation data.
function_values (Optional[torch.Tensor]) -- Function values for the point cloud.
model (nn.Module) -- Model name.
device (torch.device) -- Device to run the model on.
data (dict) -- Dictionary containing the input data.
model_path (Path) -- Path to the model state dictionary.
model -- Loaded model.
config_path (Path) -- Path to the configuration file.
cfg (dict) -- Configuration dictionary.
patch_loader (PatchLoader) -- Patch loader object.
- estimate_quantities(scalar_names: list[str]) dict [source]
Estimate geometric quantities on the point cloud. This function returns a dictionary containing the estimated scalar and/or vector values.
- Parameters:
scalar_names (list[str]) -- List of scalar names to estimate. This can be any of the following: 'xyz_coordinates', 'normals', 'tangents', 'mean_curvature', 'gaussian_curvature', 'pca_coordinates', 'normals_pca', 'tangents_pca', 'metric', 'shape', 'weingarten', 'inverse_metric', 'inverse_metric_derivatives', 'det_metric', 'laplace_beltrami_from_coefficients'
- Returns:
Dictionary containing the estimated scalar values.
- Return type:
dict
- flow_step(delta_t: float, subsample_radius: float, smooth_radius: float, smooth_x: bool) dict [source]
Perform a single step of mean curvature flow on the point cloud.
- Parameters:
delta_t (float) -- Time step for the flow.
subsample_radius (float) -- Radius used for subsampling points.
smooth_radius (float) -- Radius used for smoothing mean curvature.
smooth_x (bool) -- Whether to smooth the point cloud before flow.
- Returns:
Dictionary containing the update point cloud data, normals, and mean curvature.
- Return type:
dict
- gmls_weights(batch: Batch, radius: float = 1.0, p: int = 4) list[Tensor] [source]
Compute the weights for the generalized moving least squares (GMLS) method.
- Parameters:
batch (Batch) -- Batch containing the input data.
radius (float, optional) -- Radius to truncate weight function. Defaults to 1..
p (int, optional) -- Degree p of the weight function. Defaults to 4.
- Returns:
List of weight matrices for each batch.
- Return type:
list[torch.Tensor]
- laplace_beltrami_legendre_blocks(surface: SurfacePatch) list[Tensor] [source]
Laplace-Beltrami operator of Legendre basis functions at each center point.
- Parameters:
surface (SurfacePatch) -- Surface patch object.
- Returns:
List of outputs at each center point.
- Return type:
list[torch.Tensor]
- legendre_blocks(surface: SurfacePatch) list[Tensor] [source]
Legendre basis functions blocked by batch.
- Parameters:
surface (SurfacePatch) -- Surface patch object.
- Returns:
List of outputs per batch.
- Return type:
list[torch.Tensor]
- mean_flow(num_steps: int, save_data_per_step: int, delta_t: float, subsample_radius: float, smooth_radius: float, smooth_x: bool) list[dict] [source]
Perform mean curvature flow on the point cloud.
- Parameters:
num_steps (int) -- Number of steps to perform.
save_data_per_step (int) -- Save data every n steps.
delta_t (float) -- Time step for the flow.
subsample_radius (float) -- Radius used for subsampling points.
smooth_radius (float) -- Radius used for smoothing mean curvature.
smooth_x (bool) -- Whether to smooth the point cloud before flow.
- Returns:
List of dictionaries containing the updated point cloud data and normals at each saved time step.
- Return type:
list[dict]
- stiffness_matrix_gmls(drop_ratio: float = 0.1, radius: float = 1.0, p: int = 4, remove_outliers: bool = False) coo_matrix [source]
Compute the stiffness matrix using the generalized moving least squares (GMLS) method.
- Parameters:
drop_ratio (float, optional) -- Ratio of points to drop. Defaults to 0.1.
radius (float, optional) -- Radius to truncate weight function. Defaults to 1..
p (int, optional) -- Degree p of the weight function. Defaults to 4.
remove_outliers (bool, optional) -- Whether to remove outliers. Defaults to False.
- Returns:
Stiffness matrix.
- Return type:
sp.coo_matrix
- stiffness_on_batch(batch: Batch, radius: float = 1.0, p: int = 4) tuple[Tensor, Tensor] [source]
Compute the stiffness matrix on a batch of data.
- Parameters:
batch (Batch) -- Batch containing the input data.
radius (float, optional) -- Radius to truncate weight function. Defaults to 1..
p (int, optional) -- Degree p of the weight function. Defaults to 4.
- Returns:
Indices and values of the stiffness matrix.
- Return type:
torch.Tensor
- surface_patch(patch_data: Batch) SurfacePatch [source]
Create a SurfacePatch from the input patch data.
- Parameters:
patch_data (Batch) -- Batch containing the input patch data.
- Returns:
SurfacePatch object.
- Return type:
gnp.utils module
- gnp.utils.smooth_values_by_gaussian(x: Tensor, values: Tensor, radius: float) Tensor [source]
Smooth values by a truncated Gaussian kernel over a given radius. This is used in simulating mean curvature flow.
- Parameters:
x (torch.Tensor) -- Input data points
values (torch.Tensor) -- Values to be smoothed
radius (float) -- Radius for truncating the Gaussian kernel. The standard deviation of the Gaussian is set to one third of the radius.
- Returns:
Smoothed values
- Return type:
torch.Tensor
- gnp.utils.subsample_points_by_radius(x: Tensor, radius: float) LongTensor [source]
Subsample points by radius. This is used in simulating mean curvature flow.
- Parameters:
x (torch.Tensor) -- Points to subsample
radius (float) -- Radius for subsampling
- Returns:
Indices of subsampled points
- Return type:
torch.LongTensor