MCPcopy Create free account
hub / github.com/InternRobotics/G2VLM / seed_anything

Function seed_anything

modeling/pi3/utils/basic.py:24–40  ·  view source on GitHub ↗
(seed: int, deterministic=False)

Source from the content-addressed store, hash-verified

22from PIL import Image
23
24def seed_anything(seed: int, deterministic=False):
25 os.environ['PYTHONHASHSEED'] = str(seed)
26 random.seed(seed)
27 np.random.seed(seed)
28 torch.manual_seed(seed)
29 torch.cuda.manual_seed(seed)
30 torch.cuda.manual_seed_all(seed)
31
32 if deterministic: # https://pytorch.org/docs/stable/notes/randomness.html
33 torch.use_deterministic_algorithms(True)
34 torch.backends.cudnn.deterministic = True
35 torch.backends.cudnn.benchmark = False
36 else: # faster, less reproducible
37 torch.use_deterministic_algorithms(False)
38 torch.backends.cudnn.deterministic = False
39 # torch.backends.cudnn.benchmark = True
40 torch.backends.cudnn.benchmark = False ############## if it is hard to select a best algorithm (to much resolution for convolution), this is much faster!
41
42def colmap_to_opencv_intrinsics(K):
43 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected