Spaces:
Running on Zero
Running on Zero
Download inference/randomness.py from hugging-apps/flashvsr-plus: direct link, hf CLI and curl.
- Browser
- Download file 366 Bytes
-
https://huggingface.co/spaces/hugging-apps/flashvsr-plus/resolve/main/inference/randomness.py
- Command line
-
hf download hf://spaces/hugging-apps/flashvsr-plus/inference/randomness.py
-
curl -L -o randomness.py https://huggingface.co/spaces/hugging-apps/flashvsr-plus/resolve/main/inference/randomness.py
366 Bytes
| from __future__ import annotations | |
| import random | |
| import numpy as np | |
| import torch | |
| DEFAULT_INFERENCE_SEED = 2026 | |
| def set_inference_seed(seed: int = DEFAULT_INFERENCE_SEED) -> None: | |
| seed = int(seed) | |
| random.seed(seed) | |
| np.random.seed(seed % (2**32)) | |
| torch.manual_seed(seed) | |
| if torch.cuda.is_available(): | |
| torch.cuda.manual_seed_all(seed) | |