Remove defaults from docstrings. (#480)

This commit is contained in:
Matthew Tancik authored and GitHub committed 2022-09-19 10:04:25 -07:00
1 parent f796a9f468
commit 8b388a3e5c
25 files changed
+106 -112

No files matched your search

+2 -2
View File
@@ -256,8 +256,8 @@ class Cameras:
Args:
camera_idx: Index of the camera to convert.
image: An image in range [0, 1] that is encoded to a base64 string. Defaults to None.
max_size: Max size to resize the image to. Defaults to None.
image: An image in range [0, 1] that is encoded to a base64 string.
max_size: Max size to resize the image to if present.
Returns:
A JSON representation of the camera
+8 -8
View File
@@ -128,7 +128,7 @@ class LocalWriterConfig(InstantiateConfig):
"""Instantiate local writer
Args:
banner_messages: List of strings that always print at the bottom of screen. Defaults to None.
banner_messages: List of strings that always print at the bottom of screen.
"""
return self._target(self, banner_messages=banner_messages, **kwargs)
@@ -257,9 +257,9 @@ class ModelConfig(InstantiateConfig):
loss_coefficients: Dict[str, float] = to_immutable_dict({"rgb_loss_coarse": 1.0, "rgb_loss_fine": 1.0})
"""Loss specific weights."""
num_coarse_samples: int = 64
"""Number of samples in coarse field evaluation. Defaults to 64"""
"""Number of samples in coarse field evaluation"""
num_importance_samples: int = 128
"""Number of samples in fine field evaluation. Defaults to 128"""
"""Number of samples in fine field evaluation"""
enable_density_field: bool = False
"""Whether to create a density field to filter samples."""
density_field_params: Dict[str, Any] = to_immutable_dict(
@@ -292,20 +292,20 @@ class NerfWModelConfig(ModelConfig):
)
"""Loss specific weights."""
num_coarse_samples: int = 64
"""Number of samples in coarse field evaluation. Defaults to 64,"""
"""Number of samples in coarse field evaluation."""
num_importance_samples: int = 64
"""Number of samples in fine field evaluation. Defaults to 128,"""
"""Number of samples in fine field evaluation."""
uncertainty_min: float = 0.03
"""This is added to the end of the uncertainty
rendering operation. It's called 'beta_min' in other repos.
This avoids calling torch.log() on a zero value, which would be undefined.
Defaults to 0.03."""
"""
num_images: int = 10000 # TODO: don't hardcode this
"""How many images exist in the dataset."""
appearance_embedding_dim: int = 48
"""Dimension of appearance embedding. Defaults to 48."""
"""Dimension of appearance embedding."""
transient_embedding_dim: int = 16
"""Dimension of transient embedding. Defaults to 16."""
"""Dimension of transient embedding."""
@dataclass
+3 -3
View File
@@ -36,9 +36,9 @@ class CacheImageDataloader(DataLoader):
Args:
dataset: Dataset to sample from.
num_samples_to_collate: How many images to sample rays for each batch. Defaults to all images.
num_times_to_repeat_images: How often to collate new images. Defaults to every iteration.
device: Device to perform computation. Defaults to "cpu".
num_samples_to_collate: How many images to sample rays for each batch. -1 for all images.
num_times_to_repeat_images: How often to collate new images.
device: Device to perform computation.
"""
def __init__(
@@ -42,7 +42,7 @@ class InstantNGPDataParserConfig(DataParserConfig):
scale_factor: float = 1.0
"""How much to scale the camera origins by."""
scene_scale: float = 0.33
"""How much to scale the scene. Defaults to 0.33"""
"""How much to scale the scene."""
@dataclass
@@ -38,13 +38,13 @@ class MipNerf360DataParserConfig(DataParserConfig):
data_directory: Path = Path("data/mipnerf_360/garden")
"""directory specifying location of data"""
downscale_factor: int = 1
"""How much to downscale images. Defaults to 1."""
"""How much to downscale images."""
val_skip: int = 8
"""1/val_skip images to use for validation. Defaults to 8."""
"""1/val_skip images to use for validation."""
auto_scale: bool = True
"""Scale based on pose bounds. Defaults to True."""
"""Scale based on pose bounds."""
aabb_scale: float = 4
"""Scene scale, Defaults to 1.0."""
"""Scene scale."""
@dataclass
@@ -42,15 +42,13 @@ class NerfactoryDataParserConfig(DataParserConfig):
scale_factor: float = 1.0
"""How much to scale the camera origins by."""
downscale_factor: int = 1
"""How much to downscale images. Defaults to 1."""
"""How much to downscale images."""
scene_scale: float = 4.0
"""How much to scale the scene. Defaults to 4.0"""
"""How much to scale the scene."""
orientation_method: Literal["pca", "up"] = "up"
"""The method to use for orientation. Either "pca" or "up"."""
"""The method to use for orientation."""
train_split_percentage: float = 0.9
"""
The percent of images to use for training.
The remaining images are for eval. Defaults to 0.9.
"""The percent of images to use for training. The remaining images are for eval.
"""
@@ -40,14 +40,14 @@ class Record3DDataParserConfig(DataParserConfig):
data_directory: Path = Path("data/record3d/garden")
"""Location of data"""
val_skip: int = 8
"""1/val_skip images to use for validation. Defaults to 8."""
"""1/val_skip images to use for validation."""
aabb_scale: float = 4.0
"""Scene scale, Defaults to 4.0."""
"""Scene scale."""
orientation_method: Literal["pca", "up"] = "up"
"""The method to use for orientation. Either "pca" or "up"."""
"""The method to use for orientation"""
max_dataset_size: int = 150
"""Max number of images to train on. If the dataset has
more, images will be sampled approximately evenly. Defaults to 150."""
more, images will be sampled approximately evenly."""
@dataclass
+2 -2
View File
@@ -66,8 +66,8 @@ class Trainer:
Args:
config: The configuration object.
local_rank: Local rank of the process. Defaults to 0.
world_size: World size of the process. Defaults to 1.
local_rank: Local rank of the process.
world_size: World size of the process.
"""
def __init__(self, config: cfg.Config, local_rank: int = 0, world_size: int = 1):
+17 -17
View File
@@ -68,8 +68,8 @@ class ScalingAndOffset(Encoding):
Args:
in_dim: Input dimension of tensor
scaling: Scaling applied to tensor. Defaults to 1.0.
offset: Offset applied to tensor. Defaults to 0.0.
scaling: Scaling applied to tensor.
offset: Offset applied to tensor.
"""
def __init__(self, in_dim: int, scaling: float = 1.0, offset: float = 0.0) -> None:
@@ -127,7 +127,7 @@ class NeRFEncoding(Encoding):
Args:
in_tensor: For best performance, the input tensor should be between 0 and 1.
covs: Covariances of input points. Defaults to None.
covs: Covariances of input points.
Returns:
Output values will be between -1 and 1
"""
@@ -186,7 +186,7 @@ class RFFEncoding(Encoding):
Args:
in_tensor: For best performance, the input tensor should be between 0 and 1.
covs: Covariances of input points. Defaults to None.
covs: Covariances of input points.
Returns:
Output values will be between -1 and 1
@@ -212,12 +212,12 @@ class HashEncoding(Encoding):
"""Hash encoding
Args:
num_levels: Number of feature grids. Defaults to 16.
min_res: Resolution of smallest feature grid. Defaults to 16.
max_res: Resolution of largest feature grid. Defaults to 1024.
hash_table_size: Size of hash table. Defaults to 2**19.
features_per_level: Number of features per level. Defaults to 2.
hash_init_scale: Value to initialize hash grid. Defaults to 0.001.
num_levels: Number of feature grids.
min_res: Resolution of smallest feature grid.
max_res: Resolution of largest feature grid.
hash_table_size: Size of hash table.
features_per_level: Number of features per level.
hash_init_scale: Value to initialize hash grid.
"""
def __init__(
@@ -313,9 +313,9 @@ class TensorCPEncoding(Encoding):
"""Learned CANDECOMP/PARFAC (CP) decomposition encoding used in TensoRF
Args:
resolution: Resolution of grid. Defaults to 256.
num_components: Number of components per dimension. Defaults to 24.
init_scale: Initialization scale. Defaults to 0.1.
resolution: Resolution of grid.
num_components: Number of components per dimension.
init_scale: Initialization scale.
"""
def __init__(self, resolution: int = 256, num_components: int = 24, init_scale: float = 0.1) -> None:
@@ -363,9 +363,9 @@ class TensorVMEncoding(Encoding):
"""Learned vector-matrix encoding proposed by TensoRF
Args:
resolution: Resolution of grid. Defaults to 256.
num_components: Number of components per dimension. Defaults to 24.
init_scale: Initialization scale. Defaults to 0.1.
resolution: Resolution of grid.
num_components: Number of components per dimension.
init_scale: Initialization scale.
"""
plane_coef: TensorType[3, "num_components", "resolution", "resolution"]
@@ -427,7 +427,7 @@ class SHEncoding(Encoding):
"""Spherical harmonic encoding
Args:
levels: Number of spherical hamonic levels to encode. Defaults to 4.
levels: Number of spherical hamonic levels to encode.
"""
def __init__(self, levels: int = 4) -> None:
+2 -2
View File
@@ -117,9 +117,9 @@ class SHFieldHead(FieldHead):
Args:
in_dim: input dimension. If not defined in constructor, it must be set later.
levels: Number of spherical harmonics layers. Defaults to 3.
levels: Number of spherical harmonics layers.
channels: Number of channels. Defaults to 3 (ie RGB).
activation: Output activation. Defaults to None.
activation: Output activation.
"""
def __init__(
+3 -3
View File
@@ -31,9 +31,9 @@ class MLP(FieldModule):
in_dim: Input layer dimension
num_layers: Number of network layers
layer_width: Width of each MLP layer
out_dim: Ouput layer dimension. Defaults to layer_width
activation: intermediate layer activation function. Defaults to nn.ReLU.
out_activation: output activation function. Defaults to None.
out_dim: Ouput layer dimension. Uses layer_width if None.
activation: intermediate layer activation function.
out_activation: output activation function.
"""
def __init__(
+9 -9
View File
@@ -38,15 +38,15 @@ class NeRFField(Field):
"""NeRF Field
Args:
position_encoding: Position encoder. Defaults to Identity(in_dim=3).
direction_encoding: Direction encoder. Defaults to Identity(in_dim=3).
base_mlp_num_layers: Number of layers for base MLP. Defaults to 8.
base_mlp_layer_width: Width of base MLP layers. Defaults to 256.
head_mlp_num_layers: Number of layer for ourput head MLP. Defaults to 2.
head_mlp_layer_width: Width of output head MLP layers. Defaults to 128.
skip_connections: Where to add skip connection in base MLP. Defaults to (4,).
use_integrated_encoding: Used integrated samples as encoding input, Defaults to False.
spatial_distortion: Spatial distortion. Defaults to None.
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.
"""
def __init__(
+10 -10
View File
@@ -40,15 +40,15 @@ class VanillaNerfWField(Field):
Args:
num_images: How many images exist in the dataset.
position_encoding: Position encoder. Defaults to Identity(in_dim=3).
direction_encoding: Direction encoder. Defaults to Identity(in_dim=3).
base_mlp_num_layers: Number of layers for base MLP. Defaults to 8.
base_mlp_layer_width: Width of base MLP layers. Defaults to 256.
head_mlp_num_layers: Number of layer for ourput head MLP. Defaults to 2.
head_mlp_layer_width: Width of output head MLP layers. Defaults to 128.
appearance_embedding_dim:: Dimension of appearance embedding. Defaults to 48.
transient_embedding_dim:: Dimension of transient embedding. Defaults to 16.
skip_connections: Where to add skip connection in base MLP. Defaults to (4,).
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.
appearance_embedding_dim:: Dimension of appearance embedding.
transient_embedding_dim:: Dimension of transient embedding.
skip_connections: Where to add skip connection in base MLP.
"""
def __init__(
@@ -121,7 +121,7 @@ class VanillaNerfWField(Field):
Args:
ray_samples (RaySamples): Ray samples.
density_embedding (TensorType[..., "embedding_size"], optional): Density embedding. Defaults to None.
density_embedding (TensorType[..., "embedding_size"], optional): Density embedding.
Returns:
Dict[FieldHeadNames, TensorType]: Outputs of the NeRF-W field.
+7 -7
View File
@@ -38,13 +38,13 @@ class SemanticNerfField(Field):
Args:
num_semantic_classes: Number of distinct semantic classes.
position_encoding: Position encoder. Defaults to Identity(in_dim=3).
direction_encoding: Direction encoder. Defaults to Identity(in_dim=3).
base_mlp_num_layers: Number of layers for base MLP. Defaults to 8.
base_mlp_layer_width: Width of base MLP layers. Defaults to 256.
head_mlp_num_layers: Number of layer for ourput head MLP. Defaults to 2.
head_mlp_layer_width: Width of output head MLP layers. Defaults to 128.
skip_connections: Where to add skip connection in base MLP. Defaults to (4,).
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.
"""
def __init__(
+4 -4
View File
@@ -239,11 +239,11 @@ class PDFSampler(Sampler):
Args:
num_samples: Number of samples per ray
train_stratified: Randomize location within each bin during training. Defaults to True
include_original: Add original samples to ray. Defaults to True
train_stratified: Randomize location within each bin during training.
include_original: Add original samples to ray.
density_field: Density grid. If provides, samples below weight_threshold as set as invalid.
weight_threshold: Removes samples below threshold weight. Only used if density field is provided.
histogram_padding: Amount to weights prior to computing PDF. Defaults to 0.01.
histogram_padding: Amount to weights prior to computing PDF.
"""
def __init__(
@@ -276,7 +276,7 @@ class PDFSampler(Sampler):
ray_samples: Existing ray samples
weights: Weights for each bin
num_samples: Number of samples per ray
eps: Small value to prevent numerical issues. Defaults to 1e-5
eps: Small value to prevent numerical issues.
Returns:
Positions and deltas for samples along a ray
-1
View File
@@ -65,7 +65,6 @@ class NerfWModel(Model):
uncertainty_min (float, optional): This is added to the end of the uncertainty
rendering operation. It's called 'beta_min' in other repos.
This avoids calling torch.log() on a zero value, which would be undefined.
Defaults to 0.03.
"""
self.field_coarse = None
self.field_fine = None
+2 -2
View File
@@ -29,8 +29,8 @@ class ExponentialDecaySchedule(LambdaLR):
lr_init: The initial learning rate.
lr_final: The final learning rate.
max_steps: The maximum number of steps.
lr_delay_steps: The number of steps to delay the learning rate. Default is 0.
lr_delay_mult: The multiplier for the learning rate after the delay. Default is 1.0.
lr_delay_steps: The number of steps to delay the learning rate.
lr_delay_mult: The multiplier for the learning rate after the delay.
"""
def __init__(self, optimizer, lr_init, lr_final, max_steps, lr_delay_steps=0, lr_delay_mult=1.0) -> None:
+7 -9
View File
@@ -27,7 +27,7 @@ Example:
"""
import math
from typing import Optional
from typing import Literal, Optional
import nerfacc
import torch
@@ -42,7 +42,7 @@ class RGBRenderer(nn.Module):
"""Standard volumetic rendering.
Args:
background_color: Background color as RGB. Defaults to random.
background_color: Background color as RGB. Uses random colors if None.
"""
def __init__(self, background_color: Optional[TensorType[3]] = None) -> None:
@@ -63,7 +63,7 @@ class RGBRenderer(nn.Module):
Args:
rgb: RGB for each sample
weights: Weights for each sample
background_color: Background color as RGB. Defaults to random.
background_color: Background color as RGB. Uses random colors if None.
ray_indices: Ray index for each sample, used when samples are packed.
num_rays: Number of rays, used when samples are packed.
@@ -115,8 +115,8 @@ class SHRenderer(nn.Module):
"""Render RGB value from spherical harmonics.
Args:
background_color: Background color as RGB. Defaults to random.
activation: Output activation. Defaults to Sigmoid().
background_color: Background color as RGB. Uses random colors if None
activation: Output activation.
"""
def __init__(
@@ -191,13 +191,11 @@ class DepthRenderer(nn.Module):
"""Calculate depth along ray.
Args:
method (str, optional): Depth calculation method. Defaults to 'expected'.
method (str, optional): Depth calculation method.
"""
def __init__(self, method: str = "expected") -> None:
def __init__(self, method: Literal["expected"] = "expected") -> None:
super().__init__()
if method not in {"expected"}:
raise ValueError(f"{method} is an invalid depth calculation method")
self.method = method
def forward(
+1 -1
View File
@@ -75,7 +75,7 @@ def get_git_root(path: str, dirs: Tuple[str] = (".git",), default: str = "") ->
Args:
path: The path to start from.
dirs: The directories to look for. Defaults to (".git",).
dirs: The directories to look for.
default: The default value to return if no git root is found.
Returns:
+7 -7
View File
@@ -28,7 +28,7 @@ def apply_colormap(image: TensorType["bs":..., 1], cmap="viridis") -> TensorType
Args:
image: Single channel image.
cmap: Colormap for image. Defaults to 'turbo'.
cmap: Colormap for image.
Returns:
TensorType: Colored image
@@ -55,10 +55,10 @@ def apply_depth_colormap(
Args:
depth: Depth image.
accumulation: Ray accumulation used for masking vis. Defaults to None.
near_plane: Closest depth to consider. If None, use min image value. Defaults to None.
far_plane: Furthest depth to consider. If None, use max image value. Defaults to None.
cmap: Colormap to apply. Defaults to "turbo".
accumulation: Ray accumulation used for masking vis.
near_plane: Closest depth to consider. If None, use min image value.
far_plane: Furthest depth to consider. If None, use max image value.
cmap: Colormap to apply.
Returns:
Colored depth image
@@ -88,8 +88,8 @@ def apply_boolean_colormap(
Args:
image: Boolean image.
true_color: Color to use for True. Defaults to white.
false_color: Color to use for False. Defaults to black.
true_color: Color to use for True.
false_color: Color to use for False.
Returns:
Colored boolean image
+1 -1
View File
@@ -38,7 +38,7 @@ def run_viewer_bridge_server_as_subprocess(zmq_port: int, websocket_port: int, l
Args:
zmq_port: Port to use for the ZMQ server.
websocket_port: Port to use for the websocket server.
log_filename: Filename to use for the log file. Defaults to None. If None, no log file is created.
log_filename: Filename to use for the log file. If None, no log file is created.
Returns:
None
+2 -2
View File
@@ -90,8 +90,8 @@ class Viewer:
"""Viewer class for connecting to the bridge server.
Args:
zmq_url: Where to connect with ZMQ. Defaults to None.
window: An already existing ViewerWindow. Defaults to None.
zmq_url: Where to connect with ZMQ.
window: An already existing ViewerWindow.
"""
def __init__(self, zmq_url: Optional[str] = None, window: Optional[ViewerWindow] = None):