Download microsoftexcel-controlnet/annotator/zoe/zoedepth/utils/arg_utils.py from toto10/extensions: direct link, hf CLI and curl.
- Browser
- Download file 624 Bytes
-
https://huggingface.co/toto10/extensions/resolve/refs%2Fpr%2F2/microsoftexcel-controlnet/annotator/zoe/zoedepth/utils/arg_utils.py
- Command line
-
hf download hf://toto10/extensions@refs/pr/2/microsoftexcel-controlnet/annotator/zoe/zoedepth/utils/arg_utils.py
-
curl -L -o arg_utils.py https://huggingface.co/toto10/extensions/resolve/refs%2Fpr%2F2/microsoftexcel-controlnet/annotator/zoe/zoedepth/utils/arg_utils.py
624 Bytes
| def infer_type(x): # hacky way to infer type from string args | |
| if not isinstance(x, str): | |
| return x | |
| try: | |
| x = int(x) | |
| return x | |
| except ValueError: | |
| pass | |
| try: | |
| x = float(x) | |
| return x | |
| except ValueError: | |
| pass | |
| return x | |
| def parse_unknown(unknown_args): | |
| clean = [] | |
| for a in unknown_args: | |
| if "=" in a: | |
| k, v = a.split("=") | |
| clean.extend([k, v]) | |
| else: | |
| clean.append(a) | |
| keys = clean[::2] | |
| values = clean[1::2] | |
| return {k.replace("--", ""): infer_type(v) for k, v in zip(keys, values)} | |