Spaces:
Running on Zero
Running on Zero
| """Small runtime helpers used by the offline and online inference entrypoints.""" | |
| import random | |
| import numpy as np | |
| import torch | |
| def set_seed(seed: int, deterministic: bool = False) -> None: | |
| """Seed Python, NumPy, and PyTorch for reproducible inference.""" | |
| random.seed(seed) | |
| np.random.seed(seed) | |
| torch.manual_seed(seed) | |
| torch.cuda.manual_seed_all(seed) | |
| if deterministic: | |
| torch.use_deterministic_algorithms(True) | |