Fields#

Base#

Base class for the graphs.

class nerfstudio.fields.base_field.Field#

Bases: Module

Base class for fields.

density_fn(positions: Tensor) Tensor#

Returns only the density. Used primarily with the density grid.

Parameters:

positions – the origin of the samples/frustums

forward(ray_samples: RaySamples, compute_normals: bool = False)#

Evaluates the field at points along the ray.

Parameters:

ray_samples – Samples to evaluate field on.

abstract get_density(ray_samples: RaySamples) Tuple[Tensor, Tensor]#

Computes and returns the densities. Returns a tensor of densities and a tensor of features.

Parameters:

ray_samples – Samples locations to compute density.

get_normals() Tensor#

Computes and returns a tensor of normals.

Parameters:

density – Tensor of densities.

abstract get_outputs(ray_samples: RaySamples, density_embedding: Optional[TensorType] = None) Dict[FieldHeadNames, TensorType]#

Computes and returns the colors. Returns output field values.

Parameters:
  • ray_samples – Samples locations to compute outputs.

  • density_embedding – Density embeddings to condition on.

Instant NGP#

Instant-NGP field implementations using tiny-cuda-nn, torch, ….

class nerfstudio.fields.instant_ngp_field.TCNNInstantNGPField(aabb, num_layers: int = 2, hidden_dim: int = 64, geo_feat_dim: int = 15, num_layers_color: int = 3, hidden_dim_color: int = 64, use_appearance_embedding: bool = False, num_images: Optional[int] = None, appearance_embedding_dim: int = 32, contraction_type: ContractionType = ContractionType.UN_BOUNDED_SPHERE)#

Bases: Field

TCNN implementation of the Instant-NGP field.

Parameters:
  • aabb – parameters of scene aabb bounds

  • num_layers – number of hidden layers

  • hidden_dim – dimension of hidden layers

  • geo_feat_dim – output geo feat dimensions

  • num_layers_color – number of hidden layers for color network

  • hidden_dim_color – dimension of hidden layers for color network

  • use_appearance_embedding – whether to use appearance embedding

  • num_images – number of images, requried if use_appearance_embedding is True

  • appearance_embedding_dim – dimension of appearance embedding

  • contraction_type – type of contraction

get_density(ray_samples: RaySamples)#

Computes and returns the densities. Returns a tensor of densities and a tensor of features.

Parameters:

ray_samples – Samples locations to compute density.

get_opacity(positions: Tensor, step_size) Tensor#

Returns the opacity for a position. Used primarily by the occupancy grid.

Parameters:
  • positions – the positions to evaluate the opacity at.

  • step_size – the step size to use for the opacity evaluation.

get_outputs(ray_samples: RaySamples, density_embedding: Optional[TensorType] = None)#

Computes and returns the colors. Returns output field values.

Parameters:
  • ray_samples – Samples locations to compute outputs.

  • density_embedding – Density embeddings to condition on.

nerfstudio.fields.instant_ngp_field.get_normalized_directions(directions: Tensor)#

SH encoding must be in the range [0, 1]

Parameters:

directions – batch of directions

Vanilla NeRF#

Classic NeRF field

class nerfstudio.fields.vanilla_nerf_field.NeRFField(position_encoding: ~nerfstudio.field_components.encodings.Encoding = Identity(), direction_encoding: ~nerfstudio.field_components.encodings.Encoding = Identity(), base_mlp_num_layers: int = 8, base_mlp_layer_width: int = 256, head_mlp_num_layers: int = 2, head_mlp_layer_width: int = 128, skip_connections: ~typing.Tuple[int] = (4, ), field_heads: ~typing.Tuple[~nerfstudio.field_components.field_heads.FieldHead] = (RGBFieldHead(   (activation): Sigmoid() ), ), use_integrated_encoding: bool = False, spatial_distortion: ~typing.Optional[~nerfstudio.field_components.spatial_distortions.SpatialDistortion] = None)#

Bases: Field

NeRF Field

Parameters:
  • position_encoding – Position encoder.

  • direction_encoding – Direction encoder.

  • base_mlp_num_layers – Number of layers for base MLP.

  • base_mlp_layer_width – Width of base MLP layers.

  • head_mlp_num_layers – Number of layer for ourput head MLP.

  • head_mlp_layer_width – Width of output head MLP layers.

  • skip_connections – Where to add skip connection in base MLP.

  • use_integrated_encoding – Used integrated samples as encoding input.

  • spatial_distortion – Spatial distortion.

get_density(ray_samples: RaySamples)#

Computes and returns the densities. Returns a tensor of densities and a tensor of features.

Parameters:

ray_samples – Samples locations to compute density.

get_outputs(ray_samples: RaySamples, density_embedding: Optional[TensorType] = None) Dict[FieldHeadNames, TensorType]#

Computes and returns the colors. Returns output field values.

Parameters:
  • ray_samples – Samples locations to compute outputs.

  • density_embedding – Density embeddings to condition on.