pytorch3d.implicitron.models.implicit_function.utils
utils
- pytorch3d.implicitron.models.implicit_function.utils.broadcast_global_code(embeds: Tensor, global_code: Tensor)[source]
Expands the global_code of shape (minibatch, dim) so that it can be appended to embeds of shape (minibatch, …, dim2), and appends to the last dimension of embeds.
- pytorch3d.implicitron.models.implicit_function.utils.create_embeddings_for_implicit_function(xyz_world: Tensor, xyz_in_camera_coords: bool, global_code: Tensor | None, camera: CamerasBase | None, fun_viewpool: Callable | None, xyz_embedding_function: Callable | None, diag_cov: Tensor | None = None) Tensor [source]
- pytorch3d.implicitron.models.implicit_function.utils.interpolate_line(points: Tensor, source: Tensor, **kwargs) Tensor [source]
Linearly interpolates values of source grids. The first dimension of points represents number of points and the second coordinate, for example ([[x0], [x1], …]). The first dimension of argument source represents feature and ones after that the spatial dimension.
- Parameters:
points – shape (n_grids, n_points, 1),
source – tensor of shape (n_grids, features, width),
- Returns:
interpolated tensor of shape (n_grids, n_points, features)
- pytorch3d.implicitron.models.implicit_function.utils.interpolate_plane(points: Tensor, source: Tensor, **kwargs) Tensor [source]
Bilinearly interpolates values of source grids. The first dimension of points represents number of points and the second coordinates, for example ([[x0, y0], [x1, y1], …]). The first dimension of argument source represents feature and ones after that the spatial dimension.
- Parameters:
points – shape (n_grids, n_points, 2),
source – tensor of shape (n_grids, features, width, height),
- Returns:
interpolated tensor of shape (n_grids, n_points, features)
- pytorch3d.implicitron.models.implicit_function.utils.interpolate_volume(points: Tensor, source: Tensor, **kwargs) Tensor [source]
Interpolates values of source grids. The first dimension of points represents number of points and the second coordinates, for example [[x0, y0, z0], [x1, y1, z1], …]. The first dimension of a source represents features and ones after that the spatial dimension.
- Parameters:
points – shape (n_grids, n_points, 3),
source – tensor of shape (n_grids, features, width, height, depth),
- Returns:
interpolated tensor of shape (n_grids, n_points, features)
- pytorch3d.implicitron.models.implicit_function.utils.get_rays_points_world(ray_bundle: ImplicitronRayBundle | None = None, rays_points_world: Tensor | None = None) Tensor [source]
Converts the ray_bundle to rays_points_world if rays_points_world is not defined and raises error if both are defined.
- Parameters:
ray_bundle – An ImplicitronRayBundle object or None
rays_points_world – A torch.Tensor representing ray points converted to world coordinates
- Returns:
- A torch.Tensor representing ray points converted to world coordinates
of shape [minibatch x … x pts_per_ray x 3].