mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-07 00:09:14 +08:00
Refactoring (data loading, semantic-nerf/nerf-w fixes, ...) (#8)
* in progress. camera_indices broken * faster dataloader. starting on pixel sampler logic * imagesampler and pixelsampler * lint and black * continuing merge * pytest working * fixed docs * docs * minor changes
This commit is contained in:
1 parent
1f189b3e54
commit
146332cfb6
50 files changed
+914
-831
No files matched your search
@@ -2,7 +2,13 @@
|
||||
Miscellaneous helper code.
|
||||
"""
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
from pydoc import locate
|
||||
from typing import Any, Dict
|
||||
|
||||
import torch
|
||||
from omegaconf import DictConfig
|
||||
|
||||
|
||||
class DotDict(dict):
|
||||
@@ -51,3 +57,22 @@ def get_masked_dict(d, mask):
|
||||
for key, value in d.items():
|
||||
masked_dict[key] = value[mask]
|
||||
return masked_dict
|
||||
|
||||
|
||||
def instantiate_from_dict_config(dict_config: DictConfig, **kwargs):
|
||||
"""Our version of hydra's instantiate function."""
|
||||
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
|
||||
all_kwargs = dict_config_kwargs
|
||||
all_kwargs.update(kwargs)
|
||||
instantiated_class = uninstantiated_class(**all_kwargs)
|
||||
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"""
|
||||
dhash = hashlib.md5()
|
||||
encoded = json.dumps(dictionary, sort_keys=True).encode()
|
||||
dhash.update(encoded)
|
||||
return dhash.hexdigest()
|
||||
Reference in new issue
Block a user