refactoring configs; pulled network out of graph; created trainer heirarchy (#51)

* changed config graph structure

* removed network udner graphs; added new heirarchy trainer

* fixed callback in occupancy graph

* lint

* changed register callback to setter method
This commit is contained in:
evonneng authored and GitHub committed 2022-06-15 09:06:43 -07:00
1 parent 41073540c1
commit 91ef54963c
19 files changed
+163 -134

No files matched your search

+6 -1
View File
@@ -40,7 +40,7 @@ def setup_graph(config: DictConfig, dataset_inputs: DatasetInputs, device: str)
Args:
dataset_inputs (DatasetInputs): The inputs which will be used to define the camera parameters.
"""
graph = instantiate_from_dict_config(config.network, **dataset_inputs.as_dict())
graph = instantiate_from_dict_config(config, **dataset_inputs.as_dict())
graph.to(device)
return graph
@@ -99,6 +99,11 @@ class Graph(AbstractGraph):
self.populate_collider()
self.populate_fields()
self.populate_misc_modules() # populate the modules
self.callbacks = None
def register_callbacks(self): # pylint:disable=no-self-use
"""Option to register callback for training functions"""
self.callbacks = []
def populate_collider(self):
"""Set the scene bounds collider to use."""
+11
View File
@@ -33,6 +33,7 @@ from pyrad.graphs.modules.ray_sampler import PDFSampler, UniformSampler
from pyrad.utils import colors
from pyrad.cameras.rays import RayBundle
from pyrad.utils import visualization, writer
from pyrad.utils.callbacks import Callback
class NGPGraph(Graph):
@@ -45,6 +46,16 @@ class NGPGraph(Graph):
self.field = None
super().__init__(intrinsics=intrinsics, camera_to_world=camera_to_world, **kwargs)
def register_callbacks(self) -> None:
"""defining callbacks to run after every training iteration"""
self.callbacks = [
Callback(
self.occupancy_grid.update_every_num_iters,
self.occupancy_grid.update_occupancy_grid,
density_fn=self.field.density_fn,
)
]
def populate_fields(self):
"""Set the fields."""
# torch or tiny-cuda-nn version