Spaces:
Runtime error
Runtime error
Download apple/utils.py from LLParallax/Apple: direct link, hf CLI and curl.
- Browser
- Download file 548 Bytes
-
https://huggingface.co/spaces/LLParallax/Apple/resolve/main/apple/utils.py
- Command line
-
hf download hf://spaces/LLParallax/Apple/apple/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/LLParallax/Apple/resolve/main/apple/utils.py
548 Bytes
| import argparse | |
| import random | |
| from typing import Union | |
| import numpy as np | |
| import torch | |
| # https://stackoverflow.com/a/43357954/6365092 | |
| def str2bool(v: Union[bool, str]) -> bool: | |
| if isinstance(v, bool): | |
| return v | |
| if v.lower() in ("yes", "true", "t", "y", "1"): | |
| return True | |
| elif v.lower() in ("no", "false", "f", "n", "0"): | |
| return False | |
| else: | |
| raise argparse.ArgumentTypeError("Boolean value expected.") | |
| def set_seed(seed): | |
| random.seed(seed) | |
| np.random.seed(seed) | |
| torch.manual_seed(seed) | |