(seed: int, deterministic=False)
| 22 | from PIL import Image |
| 23 | |
| 24 | def 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 | |
| 42 | def colmap_to_opencv_intrinsics(K): |
| 43 | """ |
nothing calls this directly
no outgoing calls
no test coverage detected