MCPcopy Create free account
hub / github.com/NVlabs/InstantSplat / safe_state

Function safe_state

utils/general_utils.py:112–133  ·  view source on GitHub ↗
(silent)

Source from the content-addressed store, hash-verified

110 return L
111
112def safe_state(silent):
113 old_f = sys.stdout
114 class F:
115 def __init__(self, silent):
116 self.silent = silent
117
118 def write(self, x):
119 if not self.silent:
120 if x.endswith("\n"):
121 old_f.write(x.replace("\n", " [{}]\n".format(str(datetime.now().strftime("%d/%m %H:%M:%S")))))
122 else:
123 old_f.write(x)
124
125 def flush(self):
126 old_f.flush()
127
128 sys.stdout = F(silent)
129
130 random.seed(0)
131 np.random.seed(0)
132 torch.manual_seed(0)
133 torch.cuda.set_device(torch.device("cuda:0"))

Callers 1

train.pyFile · 0.90

Calls 2

FClass · 0.85
deviceMethod · 0.80

Tested by

no test coverage detected