sam2ai commited on
Commit
3acbfb4
·
1 Parent(s): 0b80183

Synced repo using 'sync_with_huggingface' Github Action

Browse files
Files changed (1) hide show
  1. utils/utils.py +40 -0
utils/utils.py CHANGED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import hashlib
2
+ import os
3
+ import tarfile
4
+ import urllib.request
5
+
6
+ from tqdm import tqdm
7
+
8
+
9
+ def print_arguments(args):
10
+ print("----------- Configuration Arguments -----------")
11
+ for arg, value in vars(args).items():
12
+ print("%s: %s" % (arg, value))
13
+ print("------------------------------------------------")
14
+
15
+
16
+ def strtobool(val):
17
+ val = val.lower()
18
+ if val in ('y', 'yes', 't', 'true', 'on', '1'):
19
+ return True
20
+ elif val in ('n', 'no', 'f', 'false', 'off', '0'):
21
+ return False
22
+ else:
23
+ raise ValueError("invalid truth value %r" % (val,))
24
+
25
+
26
+ def str_none(val):
27
+ if val == 'None':
28
+ return None
29
+ else:
30
+ return val
31
+
32
+
33
+ def add_arguments(argname, type, default, help, argparser, **kwargs):
34
+ type = strtobool if type == bool else type
35
+ type = str_none if type == str else type
36
+ argparser.add_argument("--" + argname,
37
+ default=default,
38
+ type=type,
39
+ help=help + ' Default: %(default)s.',
40
+ **kwargs)