multimodalart's picture
multimodalart HF Staff
Upload folder using huggingface_hub
5c93746 verified
Raw
History Blame Contribute Delete
448 Bytes
"""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)