Download pointcept/utils/env.py from dfki-av/BIMStruct3D-segmentation: direct link, hf CLI and curl.
- Browser
- Download file 755 Bytes
-
https://huggingface.co/dfki-av/BIMStruct3D-segmentation/resolve/7ab05dd198d38ea08e60bb1e4f3f04aa369975c2/pointcept/utils/env.py
- Command line
-
hf download hf://dfki-av/BIMStruct3D-segmentation@7ab05dd198d38ea08e60bb1e4f3f04aa369975c2/pointcept/utils/env.py
-
curl -L -o env.py https://huggingface.co/dfki-av/BIMStruct3D-segmentation/resolve/7ab05dd198d38ea08e60bb1e4f3f04aa369975c2/pointcept/utils/env.py
755 Bytes
| """ | |
| Environment Utils | |
| Author: Xiaoyang Wu (xiaoyang.wu.cs@gmail.com) | |
| Please cite our work if the code is helpful to you. | |
| """ | |
| import os | |
| import random | |
| import numpy as np | |
| import torch | |
| import torch.backends.cudnn as cudnn | |
| from datetime import datetime | |
| def get_random_seed(): | |
| seed = ( | |
| os.getpid() | |
| + int(datetime.now().strftime("%S%f")) | |
| + int.from_bytes(os.urandom(2), "big") | |
| ) | |
| return seed | |
| def set_seed(seed=None): | |
| if seed is None: | |
| seed = get_random_seed() | |
| random.seed(seed) | |
| np.random.seed(seed) | |
| torch.manual_seed(seed) | |
| torch.cuda.manual_seed(seed) | |
| torch.cuda.manual_seed_all(seed) | |
| cudnn.benchmark = False | |
| cudnn.deterministic = True | |
| os.environ["PYTHONHASHSEED"] = str(seed) | |