Config restructure (#283)

* starting docs for pipelines

* working on an example

* clearing output

* starting to implement config changes and add documentation

* wip: removed cicular imports; porting basic config into python; todo: get python setups workin

* circular imports again

* wip: pausing at dataloader sort of working

* break for today

* running vanilla

* wip need to get all the config docs working

* laptop about to die

* instant ngp working

* added all configs for all methods; not tested yet: [mipnerf360, nerfw, semantic_nerf]

* unpacking later

* done with pylinting

* mostly done. just need to do docs and one test

* added import order to docs

* fixing near/far plane and other config things

* making loggers also instantiable via configs

* docs

* lint

* making --help work with dcargs

* moving configs back into flat

* convert list to tuples; fixed post init function with mutable params

* lint

* made run_eval and benchmarking scripts compatible with new config/dcargs

* lint

* added option to load configs from presaved config

Co-authored-by: evonneng <evonne_ng@berkeley.edu>
This commit is contained in:
Ethan Weberandevonneng authored and GitHub committed 2022-08-26 17:25:10 -07:00
1 parent e0856e3afc
commit 7e9a56fac4
46 files changed
+987 -916

No files matched your search

+13 -2
View File
@@ -15,16 +15,19 @@
"""
Semantic NeRF implementation.
"""
from __future__ import annotations
import torch
from torch import nn
from nerfactory.cameras.rays import RayBundle
from nerfactory.configs import base as cfg
from nerfactory.dataloaders.structs import Semantics
from nerfactory.fields.modules.encoding import NeRFEncoding
from nerfactory.fields.modules.field_heads import FieldHeadNames
from nerfactory.fields.nerf_field import NeRFField
from nerfactory.fields.semantic_nerf_field import SemanticNerfField
from nerfactory.models.modules.scene_colliders import AABBBoxCollider
from nerfactory.models.vanilla_nerf import NeRFModel
from nerfactory.renderers.renderers import SemanticRenderer
from nerfactory.utils import misc, writer
@@ -33,10 +36,10 @@ from nerfactory.utils import misc, writer
class SemanticNerfModel(NeRFModel):
"""Semantic-NeRF model"""
def __init__(self, semantics: Semantics, **kwargs) -> None:
def __init__(self, config: cfg.ModelConfig, semantics: Semantics, **kwargs) -> None:
self.stuff_classes = semantics.stuff_classes
self.stuff_colors = semantics.stuff_colors
super().__init__(**kwargs)
super().__init__(config=config, **kwargs)
def populate_fields(self):
"""Set the fields."""
@@ -55,9 +58,17 @@ class SemanticNerfModel(NeRFModel):
def populate_misc_modules(self):
super().populate_misc_modules()
# renderers
self.renderer_semantic = SemanticRenderer()
# losses
self.cross_entropy_loss = nn.CrossEntropyLoss(reduction="mean")
# colliders
if self.config.enable_collider:
self.collider = AABBBoxCollider(scene_bounds=self.scene_bounds)
def get_outputs(self, ray_bundle: RayBundle):
# uniform sampling
ray_samples_uniform = self.sampler_uniform(ray_bundle)