Spaces:
Running on Zero
Running on Zero
Download timm/utils/misc.py from hugging-apps/progresvit-classify: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/spaces/hugging-apps/progresvit-classify/resolve/main/timm/utils/misc.py
- Command line
-
hf download hf://spaces/hugging-apps/progresvit-classify/timm/utils/misc.py
-
curl -L -o misc.py https://huggingface.co/spaces/hugging-apps/progresvit-classify/resolve/main/timm/utils/misc.py
1.11 kB
| """ Misc utils | |
| Hacked together by / Copyright 2020 Ross Wightman | |
| """ | |
| import argparse | |
| import ast | |
| import re | |
| def natural_key(string_): | |
| """See http://www.codinghorror.com/blog/archives/001018.html""" | |
| return [int(s) if s.isdigit() else s for s in re.split(r'(\d+)', string_.lower())] | |
| def add_bool_arg(parser, name, default=False, help=''): | |
| dest_name = name.replace('-', '_') | |
| group = parser.add_mutually_exclusive_group(required=False) | |
| group.add_argument('--' + name, dest=dest_name, action='store_true', help=help) | |
| group.add_argument('--no-' + name, dest=dest_name, action='store_false', help=help) | |
| parser.set_defaults(**{dest_name: default}) | |
| class ParseKwargs(argparse.Action): | |
| def __call__(self, parser, namespace, values, option_string=None): | |
| kw = {} | |
| for value in values: | |
| key, value = value.split('=') | |
| try: | |
| kw[key] = ast.literal_eval(value) | |
| except ValueError: | |
| kw[key] = str(value) # fallback to string (avoid need to escape on command line) | |
| setattr(namespace, self.dest, kw) | |