MCPcopy Create free account
hub / github.com/OpenImagingLab/4DSloMo / safe_state

Function safe_state

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

Source from the content-addressed store, hash-verified

145 return L
146
147def safe_state(silent):
148 old_f = sys.stdout
149 class F:
150 def __init__(self, silent):
151 self.silent = silent
152
153 def write(self, x):
154 if not self.silent:
155 if x.endswith("\n"):
156 old_f.write(x.replace("\n", " [{}]\n".format(str(datetime.now().strftime("%d/%m %H:%M:%S")))))
157 else:
158 old_f.write(x)
159
160 def flush(self):
161 old_f.flush()
162
163 sys.stdout = F(silent)
164
165 random.seed(0)
166 np.random.seed(0)
167 torch.manual_seed(0)
168 torch.cuda.set_device(torch.device("cuda:0"))
169
170def knn(x, src, k, transpose=False):
171 if transpose:

Callers 2

train.pyFile · 0.90
render.pyFile · 0.90

Calls 1

FClass · 0.85

Tested by

no test coverage detected