forked from SpeechColab/Leaderboard
-
Notifications
You must be signed in to change notification settings - Fork 1
/
push
executable file
·70 lines (54 loc) · 2.33 KB
/
push
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python3
import sys, os
import argparse
import yaml # pip install pyyaml
import logging
logging.basicConfig(stream=sys.stderr, level=logging.INFO, format='%(asctime)s [%(levelname)s] %(message)s')
MODEL_ZOO = os.path.abspath('models'); assert os.path.isdir(MODEL_ZOO)
DATASET_ZOO = os.path.abspath('datasets'); assert os.path.isdir(DATASET_ZOO)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-m', '--model', type = str)
parser.add_argument('-d', '--dataset', type = str)
args = parser.parse_args()
logging.info(args)
if not os.path.isfile('utils/oss'):
logging.error("Please install oss via utils/install_aliyun_oss_client.sh")
sys.exit(-1)
if not os.path.isfile('credentials/aliyun_oss.cfg'):
instructions_to_get_credential = (
'You need credential to use the leaderboard:\n '
'Please send email with title "oss.cfg" to [email protected], '
'and paste replied content to credentials/aliyun_oss.cfg'
)
logging.error(instructions_to_get_credential)
sys.exit(-1)
if args.model and not args.dataset:
model_id = args.model
dir = os.path.join(MODEL_ZOO, model_id)
for x in ['model.yaml', 'SBI', 'docker/Dockerfile']:
assert(os.path.isfile(os.path.join(dir, x)))
src = dir
with open(os.path.join(MODEL_ZOO, 'zoo.yaml'), 'r', encoding='utf8') as f:
remote_model_zoo = yaml.safe_load(f)
dst = remote_model_zoo[model_id]['url']
elif args.dataset and not args.model:
dataset_id = args.dataset
dir = os.path.join(DATASET_ZOO, dataset_id)
assert(os.path.isfile(os.path.join(dir, 'metadata.tsv')))
assert(
os.path.isdir(os.path.join(dir, 'audio')) or os.path.isdir(os.path.join(dir, 'wav'))
)
src = dir
with open(os.path.join(DATASET_ZOO, 'zoo.yaml'), 'r', encoding='utf8') as f:
remote_dataset_zoo = yaml.safe_load(f)
dst = remote_dataset_zoo[dataset_id]['url']
else:
logging.info(
F'\n {__file__} -m <MODEL_ID>\n'
F'\n {__file__} -d <DATASET_ID>\n'
)
exit(0)
cmd = F'utils/oss -c credentials/aliyun_oss.cfg cp -ur {src} {dst}'
logging.info(cmd)
os.system(cmd)