mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-28 20:10:05 +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
@@ -19,23 +19,9 @@ Miscellaneous helper code.
|
||||
import hashlib
|
||||
import json
|
||||
from math import floor, log
|
||||
from pydoc import locate
|
||||
from typing import Any, Callable, Dict, Union
|
||||
|
||||
import torch
|
||||
from omegaconf import DictConfig
|
||||
|
||||
|
||||
class DotDict(dict):
|
||||
"""
|
||||
dot.notation access to dictionary attributes
|
||||
"""
|
||||
|
||||
def __getattr__(self, attr):
|
||||
return self[attr]
|
||||
|
||||
__setattr__ = dict.__setitem__ # type: ignore
|
||||
__delattr__ = dict.__delitem__ # type: ignore
|
||||
|
||||
|
||||
def get_dict_to_torch(stuff, device: Union[torch.device, str] = "cpu"):
|
||||
@@ -74,23 +60,6 @@ def get_masked_dict(d, mask):
|
||||
return masked_dict
|
||||
|
||||
|
||||
def instantiate_from_dict_config(dict_config: Any, **kwargs):
|
||||
"""Our version of hydra's instantiate function.
|
||||
|
||||
Args:
|
||||
dict_config: DictConfig object to instantiate. It can be a dataclass or a dict but must have a `_target_` field.
|
||||
"""
|
||||
dict_config_kwargs = {k: v for k, v in dict_config.items() if k != "_target_"}
|
||||
uninstantiated_class = locate(dict_config._target_) # pylint: disable=protected-access
|
||||
assert (
|
||||
uninstantiated_class is not None
|
||||
), f"Could not find class {dict_config._target_}" # pylint: disable=protected-access
|
||||
all_kwargs = dict_config_kwargs
|
||||
all_kwargs.update(kwargs)
|
||||
instantiated_class = uninstantiated_class(**all_kwargs) # type: ignore
|
||||
return instantiated_class
|
||||
|
||||
|
||||
def get_hash_str_from_dict(dictionary: Dict[str, Any]) -> str:
|
||||
"""MD5 hash of a dictionary. Based on
|
||||
https://www.doc.ic.ac.uk/~nuric/coding/how-to-hash-a-dictionary-in-python.html"""
|
||||
@@ -150,7 +119,7 @@ def human_format(num):
|
||||
return f"{(num / k**magnitude):.2f} {units[magnitude]}"
|
||||
|
||||
|
||||
def scale_dict(dictionary: Dict[Any, Any], coefficients: DictConfig) -> Dict[Any, Any]:
|
||||
def scale_dict(dictionary: Dict[Any, Any], coefficients: Dict[str, float]) -> Dict[Any, Any]:
|
||||
"""Scale a dictionary in-place given a coefficients dictionary.
|
||||
|
||||
Args:
|
||||
|
||||
Reference in new issue
Block a user