mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-04 14:58:55 +08:00
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:
1 parent
e0856e3afc
commit
7e9a56fac4
46 files changed
+987
-916
No files matched your search
@@ -15,18 +15,18 @@
|
||||
"""
|
||||
Abstracts for the Pipeline class.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from abc import abstractmethod
|
||||
from pydoc import locate
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from torch import nn
|
||||
from torch.nn import Parameter
|
||||
|
||||
from nerfactory.dataloaders.base import Dataloader, setup_dataloader
|
||||
from nerfactory.models.base import Model, setup_model
|
||||
from nerfactory.configs import base as cfg
|
||||
from nerfactory.dataloaders.base import Dataloader
|
||||
from nerfactory.models.base import Model
|
||||
from nerfactory.utils import profiler
|
||||
from nerfactory.utils.config import PipelineConfig
|
||||
|
||||
|
||||
class Pipeline(nn.Module):
|
||||
@@ -70,10 +70,13 @@ class Pipeline(nn.Module):
|
||||
self.model (Model): The model that will be used
|
||||
"""
|
||||
|
||||
def __init__(self, dataloader: Dataloader, model: Model):
|
||||
def __init__(self, config: cfg.PipelineConfig, device: str, test_mode: bool = False):
|
||||
super().__init__()
|
||||
self.dataloader: Dataloader = dataloader
|
||||
self.model: Model = model
|
||||
self.dataloader: Dataloader = config.dataloader.setup(device=device, test_mode=test_mode)
|
||||
self.dataloader.to(device)
|
||||
# TODO(ethan): get rid of scene_bounds from the model
|
||||
self.model: Model = config.model.setup(scene_bounds=self.dataloader.train_datasetinputs.scene_bounds)
|
||||
self.model.to(device)
|
||||
|
||||
@property
|
||||
def device(self):
|
||||
@@ -123,19 +126,3 @@ class Pipeline(nn.Module):
|
||||
model_params = self.model.get_param_groups()
|
||||
# TODO(ethan): assert that key names don't overlap
|
||||
return {**dataloader_params, **model_params}
|
||||
|
||||
|
||||
@profiler.time_function
|
||||
def setup_pipeline(config: PipelineConfig, device: str, test_mode=False) -> Pipeline:
|
||||
"""Setup the pipeline. The dataset inputs should be set with the training data.
|
||||
|
||||
Args:
|
||||
config: The pipeline config.
|
||||
"""
|
||||
# dataset_inputs
|
||||
dataloader: Dataloader = setup_dataloader(config.dataloader, device=device, test_mode=test_mode)
|
||||
# TODO(ethan): get rid of scene_bounds from the model
|
||||
model: Model = setup_model(config.model, scene_bounds=dataloader.train_datasetinputs.scene_bounds, device=device)
|
||||
pipeline_class = locate(config._target_) # pylint: disable=protected-access
|
||||
pipeline = pipeline_class(dataloader=dataloader, model=model) # type: ignore
|
||||
return pipeline
|
||||
Reference in new issue
Block a user