Spaces:
Runtime error
Runtime error
Download src/utils/seed.py from mshaiel2004/dr-severity-grading: direct link, hf CLI and curl.
- Browser
- Download file 577 Bytes
-
https://huggingface.co/spaces/mshaiel2004/dr-severity-grading/resolve/main/src/utils/seed.py
- Command line
-
hf download hf://spaces/mshaiel2004/dr-severity-grading/src/utils/seed.py
-
curl -L -o seed.py https://huggingface.co/spaces/mshaiel2004/dr-severity-grading/resolve/main/src/utils/seed.py
577 Bytes
| import os | |
| import random | |
| import numpy as np | |
| import torch | |
| def seed_everything(seed: int = 42) -> None: | |
| """Set seeds for reproducibility across Python, NumPy, and PyTorch. | |
| Args: | |
| seed: The integer seed value. Defaults to 42. | |
| """ | |
| random.seed(seed) | |
| os.environ["PYTHONHASHSEED"] = str(seed) | |
| np.random.seed(seed) | |
| torch.manual_seed(seed) | |
| if torch.cuda.is_available(): | |
| torch.cuda.manual_seed(seed) | |
| torch.cuda.manual_seed_all(seed) | |
| torch.backends.cudnn.deterministic = True | |
| torch.backends.cudnn.benchmark = False | |