mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-04 14:58:55 +08:00
Fixed testing and added graph abstractions (#64)
* abstracted some test logic and actually using test images now * moved logging from trainer to graph * fixing dataset path * refactored instant ngp code to use inheritance * fixed my run_train * fixed data path * fixed data dir
This commit is contained in:
1 parent
e83ce4f61b
commit
5fb3d14304
26 files changed
+8526
-270
No files matched your search
@@ -2,6 +2,8 @@
|
||||
Miscellaneous helper code.
|
||||
"""
|
||||
|
||||
import torch
|
||||
|
||||
|
||||
class DotDict(dict):
|
||||
"""
|
||||
@@ -13,3 +15,25 @@ class DotDict(dict):
|
||||
|
||||
__setattr__ = dict.__setitem__
|
||||
__delattr__ = dict.__delitem__
|
||||
|
||||
|
||||
def get_dict_to_torch(stuff, device="cpu"):
|
||||
"""Set everything in the dict to the specified torch device."""
|
||||
if isinstance(stuff, dict):
|
||||
for k, v in stuff.items():
|
||||
stuff[k] = get_dict_to_torch(v, device)
|
||||
return stuff
|
||||
if isinstance(stuff, torch.Tensor):
|
||||
return stuff.to(device)
|
||||
return stuff
|
||||
|
||||
|
||||
def get_dict_to_cpu(stuff):
|
||||
"""Set everything in the dict to CPU."""
|
||||
if isinstance(stuff, dict):
|
||||
for k, v in stuff.items():
|
||||
stuff[k] = get_dict_to_cpu(v)
|
||||
return stuff
|
||||
if isinstance(stuff, torch.Tensor):
|
||||
return stuff.detach().cpu()
|
||||
return stuff
|
||||
Reference in new issue
Block a user