update docstrings and random cleanups (#387)

* fixing docstrings and small nits; up to fileds

* finished adding and fixing docstrings
This commit is contained in:
evonneng authored and GitHub committed 2022-09-10 23:09:44 -07:00
1 parent bd5967461d
commit d50c71ac43
52 files changed
+846 -646

No files matched your search

+122 -7
View File
@@ -81,10 +81,15 @@ class MachineConfig(PrintableConfig):
"""Configuration of machine setup"""
seed: int = 42
"""random seed initilization"""
num_gpus: int = 1
"""total number of gpus available for train/eval"""
num_machines: int = 1
"""total number of distributed machines available (for DDP)"""
machine_rank: int = 0
"""current machine's rank (for DDP)"""
dist_url: str = "auto"
"""distributed connection point (for DDP)"""
# Logging related configs
@@ -93,9 +98,13 @@ class TensorboardWriterConfig(InstantiateConfig):
"""Tensorboard Writer config"""
_target: Type = writer.TensorboardWriter
"""target class to instantiate"""
enable: bool = False
"""if True enables tensorboard logging, else disables"""
relative_log_dir: Path = Path("./")
"""relative path to save all tensorboard events"""
log_dir: Optional[Path] = None # full log dir path to be dynamically set
"""auto populated absolute path to saved tensorboard events [Do not set!]"""
@dataclass
@@ -103,9 +112,13 @@ class WandbWriterConfig(InstantiateConfig):
"""WandDB Writer config"""
_target: Type = writer.WandbWriter
"""target class to instantiate"""
enable: bool = False
"""if True enables wandb logging, else disables"""
relative_log_dir: Path = Path("./")
"""relative path to save all wandb events"""
log_dir: Optional[Path] = None # full log dir path to be dynamically set
"""auto populated absolute path to saved wandb events [Do not set!]"""
@dataclass
@@ -113,7 +126,9 @@ class LocalWriterConfig(InstantiateConfig):
"""Local Writer config"""
_target: Type = writer.LocalWriter
"""target class to instantiate"""
enable: bool = False
"""if True enables local logging, else disables"""
stats_to_track: Tuple[writer.EventName, ...] = (
writer.EventName.ITER_TRAIN_TIME,
writer.EventName.TRAIN_RAYS_PER_SEC,
@@ -121,9 +136,13 @@ class LocalWriterConfig(InstantiateConfig):
writer.EventName.VIS_RAYS_PER_SEC,
writer.EventName.TEST_RAYS_PER_SEC,
)
"""specifies which stats will be logged/printed to terminal"""
max_log_size: int = 10
"""maximum number of rows to print before wrapping. if 0, will print everything."""
relative_log_dir: Path = Path("./")
"""relative local path to save all events"""
log_dir: Optional[Path] = None # full log dir path to be dynamically set
"""auto populated absolute local path to saved events [Do not set!]"""
def setup(self, banner_messages: Optional[List[str]] = None, **kwargs) -> Any:
"""Instantiate local writer
@@ -139,14 +158,19 @@ class LoggingConfig(PrintableConfig):
"""Configuration of loggers and profilers"""
steps_per_log: int = 10
"""number of steps between logging stats"""
max_buffer_size: int = 20
"""maximum history size to keep for computing running averages of stats.
e.g. if 20, averages will be computed over past 20 occurances."""
writer: Tuple[Any, ...] = (
TensorboardWriterConfig(enable=True),
WandbWriterConfig(enable=False),
LocalWriterConfig(enable=True),
)
# profiler logs run times of functions and prints at end of training
"""list of all supported writers. Can turn on/off writers by specifying enable."""
enable_profiler: bool = True
"""whether to enable profiling code; prints speed of functions at the end of a program.
profiler logs run times of functions and prints at end of training"""
# Trainer related configs
@@ -155,15 +179,24 @@ class TrainerConfig(PrintableConfig):
"""Configuration for training regimen"""
steps_per_save: int = 1000
"""number of steps between saves"""
steps_per_test: int = 500
"""number of steps between eval"""
max_num_iterations: int = 1000000
"""maximum number of iterations to run"""
mixed_precision: bool = False
"""whether or not to use mixed precision for training"""
relative_model_dir: Path = Path("nerfactory_models/")
"""relative path to save all checkpoints"""
model_dir: Optional[Path] = None # full model dir path to be dynamically set
"""auto populated absolute path to saved checkpoints [Do not set!]"""
# optional parameters if we want to resume training
load_dir: Optional[Path] = None
"""optionally specify a pre-trained model directory to load from"""
load_step: Optional[int] = None
"""optionally specify model step to load from; if none, will find most recent model in load_dir"""
load_config: Optional[Path] = None
"""optionally specify a pre-defined config to load from"""
# Dataset related configs
@@ -172,6 +205,7 @@ class DataParserConfig(InstantiateConfig):
"""Basic dataset config"""
_target: Type = DataParser
"""_target: target class to instantiate"""
@dataclass
@@ -179,11 +213,17 @@ class NerfactoryDataParserConfig(DataParserConfig):
"""Nerfactory dataset config"""
_target: Type = Nerfactory
"""target class to instantiate"""
data_directory: Path = Path("data/ours/posterv2")
"""directory specifying location of data"""
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."""
scene_scale: float = 4.0
"""How much to scale the scene. Defaults to 0.33"""
orientation_method: Literal["pca", "up"] = "up"
"""The method to use for orientation. Either "pca" or "up"."""
@dataclass
@@ -191,9 +231,13 @@ class BlenderDataParserConfig(DataParserConfig):
"""Blender dataset config"""
_target: Type = Blender
"""target class to instantiate"""
data_directory: Path = Path("data/blender/lego")
"""directory specifying location of data"""
scale_factor: float = 1.0
"""How much to scale the camera origins by."""
alpha_color: str = "white"
"""alpha color of background"""
@dataclass
@@ -201,8 +245,11 @@ class FriendsDataParserConfig(DataParserConfig):
"""Friends dataset config"""
_target: Type = Friends
"""target class to instantiate"""
data_directory: Path = Path("data/friends/TBBT-big_living_room")
"""directory specifying location of data"""
include_semantics: bool = True
"""whether or not to include loading of semantics data"""
@dataclass
@@ -210,11 +257,17 @@ class MipNerf360DataParserConfig(DataParserConfig):
"""Mipnerf 360 dataset config"""
_target: Type = Mipnerf360
"""target class to instantiate"""
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."""
val_skip: int = 8
"""1/val_skip images to use for validation. Defaults to 8."""
auto_scale: bool = True
"""Scale based on pose bounds. Defaults to True."""
aabb_scale = 4
"""Scene scale, Defaults to 1.0."""
@dataclass
@@ -222,9 +275,13 @@ class InstantNGPDataParserConfig(DataParserConfig):
"""Instant-NGP dataset config"""
_target: Type = InstantNGP
"""target class to instantiate"""
data_directory: Path = Path("data/ours/posterv2")
"""directory specifying location of data"""
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"""
@dataclass
@@ -232,27 +289,43 @@ class Record3DDataParserConfig(DataParserConfig):
"""Mipnerf 360 dataset config"""
_target: Type = Record3D
"""target class to instantiate"""
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."""
aabb_scale = 4.0
"""Scene scale, Defaults to 4.0."""
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."""
@dataclass
class VanillaDataManagerConfig(InstantiateConfig):
"""Configuration for data manager instantiation"""
"""Configuration for data manager instantiation; DataManager is in charge of keeping the train/eval dataparsers;
After instantiation, data manager holds both train/eval datasets and is in charge of returning unpacked
train/eval data at each iteration
"""
# Note: eval_dataparser is annotated with Fixed[] to prevent dcargs from trying to
# convert Optional[InstantiateConfig] into subcommands for choosing between None and
# InstantiateConfig.
_target: Type = VanillaDataManager
"""target class to instantiate"""
train_dataparser: DataParserConfig = BlenderDataParserConfig()
"""specifies the dataparser used to unpack the data"""
train_num_rays_per_batch: int = 1024
"""number of rays per batch to use per training iteration"""
train_num_images_to_sample_from: int = -1
"""number of images to sample during training iteration"""
eval_dataparser: dcargs.conf.Fixed[Optional[InstantiateConfig]] = None
"""optionally specify different dataparser to use during eval; if None, uses train_dataparser"""
eval_image_indices: Optional[Tuple[int, ...]] = (0,)
"""specifies the image indices to use during eval; if None, uses all"""
eval_num_rays_per_chunk: int = 4096
"""specifies number of rays per chunk during eval"""
@dataclass
@@ -260,7 +333,9 @@ class FriendsDataManagerConfig(VanillaDataManagerConfig):
"""Friends data manager config"""
_target: Type = VanillaDataManager
"""target class to instantiate"""
train_dataparser: DataParserConfig = FriendsDataParserConfig()
"""specifies the dataparser used to unpack the data"""
# Model related configs
@@ -269,13 +344,21 @@ class ModelConfig(InstantiateConfig):
"""Configuration for model instantiation"""
_target: Type = Model
"""target class to instantiate"""
enable_collider: bool = True
"""Whether to create a scene collider to filter rays."""
collider_params: Dict[str, float] = to_immutable_dict({"near_plane": 2.0, "far_plane": 6.0})
"""parameters to instantiate scene collider with"""
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"""
num_importance_samples: int = 128
"""Number of samples in fine field evaluation. Defaults to 128"""
field_implementation: Literal["torch", "tcnn"] = "torch"
"""one of "torch" or "tcnn", or other fields in 'field_implementation_to_class"""
enable_density_field: bool = False
"""Whether to create a density field to filter samples."""
density_field_params: Dict[str, Any] = to_immutable_dict(
{
"center": 0.0, # simply set it as the center of the scene bbox
@@ -285,6 +368,7 @@ class ModelConfig(InstantiateConfig):
"update_every_num_iters": 16,
}
)
"""parameters to instantiate density field with"""
@dataclass
@@ -292,11 +376,17 @@ class InstantNGPModelConfig(ModelConfig):
"""Instant NGP Model Config"""
_target: Type = NGPModel
enable_density_field: bool = True
"""target class to instantiate"""
enable_collider: bool = False
field_implementation: Literal["torch", "tcnn"] = "tcnn" # torch, tcnn, ...
"""Whether to create a scene collider to filter rays."""
loss_coefficients: Dict[str, float] = to_immutable_dict({"rgb_loss": 1.0})
"""Loss specific weights."""
field_implementation: Literal["torch", "tcnn"] = "tcnn" # torch, tcnn, ...
"""one of "torch" or "tcnn", or other fields in 'field_implementation_to_class'"""
enable_density_field: bool = True
"""Whether to create a density field to filter samples."""
num_samples: int = 1024 # instead of course/fine samples
"""Number of samples in field evaluation. Defaults to 1024,"""
@dataclass
@@ -304,15 +394,26 @@ class NerfWModelConfig(ModelConfig):
"""NerfW model config"""
_target: Type = NerfWModel
"""target class to instantiate"""
loss_coefficients: Dict[str, float] = to_immutable_dict(
{"rgb_loss_coarse": 1.0, "rgb_loss_fine": 1.0, "uncertainty_loss": 1.0, "density_loss": 0.01}
)
"""Loss specific weights."""
num_coarse_samples: int = 64
"""Number of samples in coarse field evaluation. Defaults to 64,"""
num_importance_samples: int = 64
"""Number of samples in fine field evaluation. Defaults to 128,"""
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."""
transient_embedding_dim: int = 16
"""Dimension of transient embedding. Defaults to 16."""
@dataclass
@@ -320,10 +421,15 @@ class TensoRFModelConfig(ModelConfig):
"""TensoRF model config"""
_target: Type = TensoRFModel
"""target class to instantiate"""
init_resolution: int = 128
"""initial render resolution"""
final_resolution: int = 200
"""final render resolution"""
upsampling_iters: Tuple[int, ...] = (5000, 5500, 7000)
"""specifies a list of iteration step numbers to perform upsampling"""
loss_coefficients: Dict[str, float] = to_immutable_dict({"rgb_loss_coarse": 1.0, "feature_loss": 8e-5})
"""Loss specific weights."""
# Pipeline related configs
@@ -332,8 +438,11 @@ class PipelineConfig(InstantiateConfig):
"""Configuration for pipeline instantiation"""
_target: Type = Pipeline
"""target class to instantiate"""
datamanager: VanillaDataManagerConfig = VanillaDataManagerConfig()
"""specifies the datamanager config"""
model: ModelConfig = ModelConfig()
"""specifies the model config"""
# Viewer related configs
@@ -342,14 +451,20 @@ class ViewerConfig(PrintableConfig):
"""Configuration for viewer instantiation"""
log_filename: Optional[Path] = None
"""Filename to use for the log file. Defaults to None. If None, no log file is created."""
enable: bool = False
train: bool = True
"""whether to enable viewer"""
start_train: bool = True
"""whether to immediately start training upon loading viewer
if False, will just visualize dataset but you can toggle training in viewer"""
zmq_url: str = "tcp://127.0.0.1:6000"
"""the zmq port to connect to for communication"""
launch_bridge_server: bool = True
"""whether or not to launch the zmq bridge server"""
websocket_port: int = 7007
min_render_image_height: int = 64
max_render_image_height: int = 1024
"""the default websocket port to connect to"""
num_rays_per_chunk: int = 32768
"""number of rays per chunk to render with visualizer"""
# Optimizer related configs